Series.from_csv not loading header names #10483

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

richlewis42 commented Jul 1, 2015

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!

@jreback jreback commented on an outdated diff Jul 1, 2015

pandas/tests/test_series.py
@@ -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)
@jreback

jreback Jul 1, 2015

Contributor

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

@jreback jreback added Bug CSV labels Jul 1, 2015

jreback added this to the 0.17.0 milestone Jul 1, 2015

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

@richlewis42 richlewis42 BUG: Series.from_csv not loading header names
added another test

changed to test for identity with None

added PR number as comment

added bugfix to whatsnew
61e6766
Contributor

richlewis42 commented Jul 2, 2015

Hopefully this worked, still new to git!

Contributor

richlewis42 commented Jul 7, 2015

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

Contributor

jreback commented Jul 7, 2015

merged via 3382e12

thanks!

jreback closed this Jul 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment