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

Comments

@craustin
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

commented Nov 5, 2011

Fixed this in the above commit

@wesm wesm closed this Nov 5, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.