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

Comments

@drewfrank
Copy link

commented Oct 8, 2012

Like it says in the title:

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Oct 11, 2012

:) 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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Oct 11, 2012

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

This comment has been minimized.

Copy link
Member

commented Nov 17, 2012

thanks @y-p for taking care of this!

@wesm wesm closed this Nov 17, 2012

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.