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

DataFrame header is misaligned when column names contain tabs #2038

Closed
drewfrank opened this issue Oct 8, 2012 · 5 comments
Closed

DataFrame header is misaligned when column names contain tabs #2038

drewfrank opened this issue Oct 8, 2012 · 5 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@drewfrank
Copy link

Like it says in the title:

In [10]: pd.DataFrame([{"a\tb": 1, "c": 2}])
Out[10]: 
   a    b  c
0    1  2
@wesm
Copy link
Member

wesm commented Oct 11, 2012

Fun. I guess the $64,000 question is whether there's a consistent way to see how the user's console displays a tab stop

@drewfrank
Copy link
Author

:) Yes, and I have no idea if that's possible. Maybe an alternative would be to display the tab escape sequence:

In [10]: pd.DataFrame([{"a\tb": 1, "c": 2}])
Out[10]: 
  a\tb  c
0    1  2

I would actually prefer this behavior even if magic tab alignment is possible.

@wesm
Copy link
Member

wesm commented Oct 11, 2012

I agree this would be preferable. Shouldn't be that difficult to do (though not as simple as writing the repr instead of str representation, because then unicode characters won't display properly)

@drewfrank
Copy link
Author

This may have been obvious to you from the beginning, but I just realized the same thing happens when tabs are in the contents of a DataFrame (not just the header):

In [13]: pd.DataFrame([{'a': '1\t2', 'b':'3'}])
Out[13]: 
     a  b
0  1    2  3

@wesm
Copy link
Member

wesm commented Nov 17, 2012

thanks @y-p for taking care of this!

@wesm wesm closed this as completed Nov 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

2 participants