Skip to content

API: read_csv,from_csv/to_csv keyword consistency #9568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 of 5 tasks
rmorgans opened this issue Mar 1, 2015 · 14 comments
Closed
4 of 5 tasks

API: read_csv,from_csv/to_csv keyword consistency #9568

rmorgans opened this issue Mar 1, 2015 · 14 comments
Labels
API - Consistency Internal Consistency of API/Behavior Deprecate Functionality to remove in pandas IO CSV read_csv, to_csv Needs Discussion Requires discussion from core team before further action
Milestone

Comments

@rmorgans
Copy link

rmorgans commented Mar 1, 2015

method naming consistency issue #577

@jreback jreback changed the title csv line terminator inconsistency between read and write API: read_csv/to_csv keyword consistency Mar 1, 2015
@jreback jreback added API Design IO CSV read_csv, to_csv labels Mar 1, 2015
@jreback jreback added this to the 0.17.0 milestone Mar 1, 2015
@jreback
Copy link
Contributor

jreback commented Mar 1, 2015

@rmorgans yep. I created a master issue for things that I recall, but I am sure there are some more. Would you like to do a full comparison of the read_csv/to_csv options to see if there any other conventions that are inconsisten (and include from_csv) here as well.

Ideally we would like to make most consistent name work and deprecate the others. Would you like to do a pull-request?

@jreback jreback added Good as first PR Deprecate Functionality to remove in pandas labels Mar 1, 2015
@jreback jreback changed the title API: read_csv/to_csv keyword consistency API: read_csv,from_csv/to_csv keyword consistency Mar 1, 2015
@Dobatymo
Copy link
Contributor

Dobatymo commented Nov 3, 2017

all other issues referenced here are closed.
only

to_csv uses line_terminator and read_csv uses lineterminator

still applies.

@jreback
Copy link
Contributor

jreback commented Nov 4, 2017

@Dobatymo updated. would you like to do a PR to deprecate line_terminator in .to_csv?

@Dobatymo
Copy link
Contributor

Dobatymo commented Nov 6, 2017

Not sure how to deprecate something. Should I add lineterminator and add to the docs that line_terminator is deprecated? Or directly delete it?

@TomAugspurger
Copy link
Contributor

Not sure how to deprecate something

If you look in pandas/utils/_decorators.py you'll see a deprecate_kwarg. You can use that to and it'll emit a warning if the incorrect version is passed.

We'll also want to

  1. update all the docs and tests to use lineterminator
  2. Add a new tests that uses line_terminator and checks that the deprecation warning was emitted
  3. Add a release note to whatsnew/v0.21.1.txt (@jreback we're OK with adding deprecation warnings in point releases, correct?)

@jorisvandenbossche
Copy link
Member

Add a release note to whatsnew/v0.21.1.txt (@jreback we're OK with adding deprecation warnings in point releases, correct?)

Let's keep that for 0.22.0. Introducing deprecation warnings is somehow changing behaviour in the sense that it gives annoying warnings one needs to change code for to get rid of them. I would keep 0.21.1 for essential bug fixes.

But apart from that, actual question: is there a reason we would prefer lineterminator over line_terminator ? (I find the latter more readable)

@jreback
Copy link
Contributor

jreback commented Nov 7, 2017

most 2 word options are not _ separates in read_csv and we chose previously not to change them
so lineterminator is consistent (agree it’s not as nice)

no depreciations in point release so this for 0.22

@jorisvandenbossche
Copy link
Member

most 2 word options are not _ separates in read_csv and we chose previously not to change them
so lineterminator is consistent (agree it’s not as nice)

That is not completely true (I mean we have both), eg: index_col, mangle_dupe_cols, true_values, na_values, keep_default_na, skip_blank_lines, parse_dates, infer_datetime_format, ... etc all use the _ naming scheme.
It seems that it are mainly the keyword inherited from the stdlib csv module that are not with underscores. And, lineterminator is one of those. So in read_csv we followed the csv module, in to_csv not.

Personally I find that not enough reason to choose for lineterminator in to_csv.
Another option is also to document it as line_terminator but still accept lineterminator in read_csv for compatibility with csv dialects.

@jreback
Copy link
Contributor

jreback commented Nov 7, 2017

yes I think we have an issue about accepting both. personally I would just do that, its really no big deal to do that.

@GGordonGordon
Copy link
Contributor

@jreback / @jorisvandenbossche - I was thinking of picking this up and working on it but wanted to clarify is the objective for this issue to still deprecate line_terminator in to_csv and replace it with lineterminator to mirror read_csv or is the objective to allow both parameters in both locations?

@mangecoeur
Copy link
Contributor

Bumping/adding to this: it would be good to have symmetry in the header keyword, when writing you set header=False to skip the header but when reading you set header=None (header=False is an error).

df.to_csv(header=False)

#Currently allowed
df = pd.read_csv(header=None)

#Currently an error
df = pd.read_csv(header=False)

@pv8473h12
Copy link
Contributor

If no-one else is working on this, I'd like to give it a go.

@jbrockmendel jbrockmendel added API - Consistency Internal Consistency of API/Behavior and removed API Design labels Dec 18, 2019
@mroeschke mroeschke added Needs Discussion Requires discussion from core team before further action and removed good first issue labels Apr 12, 2021
@jbrockmendel
Copy link
Member

#35399 didn't achieve any consensus. In isolation I like line_terminator better, but for consistency with stdlib csv think we should standardize on lineterminator.

@phofl
Copy link
Member

phofl commented Jan 30, 2022

closed by #45302

@phofl phofl closed this as completed Jan 30, 2022
@phofl phofl modified the milestones: Contributions Welcome, 1.5 Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Deprecate Functionality to remove in pandas IO CSV read_csv, to_csv Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

Successfully merging a pull request may close this issue.