Skip to content
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

read_csv does not set index name on empty dataframe #10184

Closed
corr723 opened this issue May 21, 2015 · 5 comments
Closed

read_csv does not set index name on empty dataframe #10184

corr723 opened this issue May 21, 2015 · 5 comments
Labels
Bug IO CSV read_csv, to_csv
Milestone

Comments

@corr723
Copy link

corr723 commented May 21, 2015

If foo.csv contains

x,y
1,2

then you get the normal behavior:

>>> df = pd.read_csv('foo.csv', index_col=0)
>>> list(df.columns)
['y']
>>> df.index.name
'x'

but if you remove the data row "1,2" in the CSV the index name gets dropped:

>>> df = pd.read_csv('foo.csv', index_col=0)
>>> list(df.columns)
['y']
>>> df.index.name
None

This means round-tripping with to_csv/read_csv fails for empty dataframes.

@jreback
Copy link
Contributor

jreback commented May 21, 2015

ok, will mark as a bug. want to do a pull-request to fix?

@jreback jreback added Bug IO CSV read_csv, to_csv labels May 21, 2015
@jreback jreback added this to the Next Major Release milestone May 21, 2015
@corr723
Copy link
Author

corr723 commented May 21, 2015

No, I don't have a patch.

@jreback
Copy link
Contributor

jreback commented May 21, 2015

@corr723 well if you would like to work on one would be gr8

@corr723
Copy link
Author

corr723 commented May 21, 2015

No plan to work on one, sorry

@jorisvandenbossche
Copy link
Member

Closed by #10302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

3 participants