Skip to content

Series.from_csv not loading header names #10483

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
wants to merge 1 commit into from

Conversation

lewisacidic
Copy link
Contributor

Series.from_csv at the moment does not load the series.name and series.index.name when the header keyword argument is stated.

This was introduced in 6078fba. The issue was that Series.from_csv uses DataFrame.from_csv, which automatically indexes columns (in practice, the index column gets labelled 0 and the values column gets labelled 1). Converting this to a series will then cause the series.name to be 1, and the series.index.name to be 0. The fix was to explicitly set the names in Series.from_csv to None.

This caused the headers to be deleted even if they were provided by setting the header kwarg.

The fix is simple, to check if the headers are provided, and only setting the names to None if they are not.

I included some tests, please let me know if this is enough as I am new to open-source and pandas.

Thanks!

@@ -4979,6 +4979,10 @@ def test_from_csv(self):
self.assertTrue(ts.name is None)
self.assertTrue(ts.index.name is None)

self.ts.to_csv(path, header=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the issues number (this PR number) as a comment

@jreback jreback added Bug IO CSV read_csv, to_csv labels Jul 1, 2015
@jreback jreback added this to the 0.17.0 milestone Jul 1, 2015
@jreback
Copy link
Contributor

jreback commented Jul 1, 2015

looks good

pls add a whatsnew note in bug-fixes (for 0.17.0)
squash and ping when green

added another test

changed to test for identity with None

added PR number as comment

added bugfix to whatsnew
@lewisacidic
Copy link
Contributor Author

Hopefully this worked, still new to git!

@lewisacidic
Copy link
Contributor Author

I think this is ready to be merged if everything looks ok?

@jreback
Copy link
Contributor

jreback commented Jul 7, 2015

merged via 3382e12

thanks!

@jreback jreback closed this Jul 7, 2015
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

Successfully merging this pull request may close these issues.

2 participants