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

to_string on DataFrame may print column labels in the wrong order #325

Closed
craustin opened this issue Nov 2, 2011 · 3 comments
Closed

to_string on DataFrame may print column labels in the wrong order #325

craustin opened this issue Nov 2, 2011 · 3 comments
Labels
Milestone

Comments

@craustin
Copy link

craustin commented Nov 2, 2011

d = {'a': [1,2,3], 'b':[4,5,6]}
from pandas import DataFrame
df = DataFrame(d)

df.to_string()

Returns:
a b
0 1 4
1 2 5
2 3 6

df.to_string(columns=['b','a'])

Returns:
a b
0 4 1
1 5 2
2 6 3

@wesm
Copy link
Member

wesm commented Nov 2, 2011

Good point. Currently the passed columns is only used to filter the columns, not actually specify an order. Obviously this is a bug, will be a simple fix (feel free to submit a pull request w/ tests if I don't get to it in the next couple days)

@craustin
Copy link
Author

craustin commented Nov 2, 2011

Yeah. Like you said, the bug is either that it reorders the columns - or that it doesn't also reorder the headers.

wesm added a commit that referenced this issue Nov 5, 2011
@wesm
Copy link
Member

wesm commented Nov 5, 2011

Fixed this in the above commit

@wesm wesm closed this as completed Nov 5, 2011
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants