Skip to content

BUG: to_excel duplicate columns #11237

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

Merged
merged 1 commit into from
Oct 10, 2015
Merged

Conversation

chris-b1
Copy link
Contributor

@chris-b1 chris-b1 commented Oct 4, 2015

closes #11007
closes #10970 (data in wrong order)
closes #10982 (columns lost).

Using the approach suggested here

All three occurred when using to_excel with duplicate columns in the DataFrame

@jreback jreback added Bug IO Excel read_excel, to_excel labels Oct 5, 2015
@jreback jreback added this to the 0.17.1 milestone Oct 5, 2015
self.rowcounter = 0
self.na_rep = na_rep
self.columns = cols
if cols is None:
if cols is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

self.df = df
if cols is not None:
    self.df = self.df.reindex(columns=cols)
self.columns = self.df.columns

@chris-b1
Copy link
Contributor Author

chris-b1 commented Oct 5, 2015

@jreback - updated for youf comments. to_csv uses loc as well so I did not change that to reindex but did add a couple tests (raises if no correct columns specified, otherwise like reindex).

@@ -1375,6 +1388,22 @@ def test_swapped_columns(self):
tm.assert_series_equal(write_frame['A'], read_frame['A'])
tm.assert_series_equal(write_frame['B'], read_frame['B'])

def test_invalid_columns(self):
_skip_if_no_xlrd()
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 issue number here

@jreback
Copy link
Contributor

jreback commented Oct 8, 2015

pls squash otherwise lgtm.

@jorisvandenbossche
Copy link
Member

Nice!

@jreback
Copy link
Contributor

jreback commented Oct 9, 2015

can you rebase/squash

@chris-b1
Copy link
Contributor Author

chris-b1 commented Oct 9, 2015

@jreback this is squashed now

jreback added a commit that referenced this pull request Oct 10, 2015
@jreback jreback merged commit cac4ad2 into pandas-dev:master Oct 10, 2015
@jreback
Copy link
Contributor

jreback commented Oct 10, 2015

thanks!

@chris-b1 chris-b1 deleted the excel-column-bugs branch October 11, 2015 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Excel read_excel, to_excel
Projects
None yet
3 participants