-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Applying max_colwidth to the DataFrame index (#7856) #8954
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
Changes from 5 commits
de1faaa
2fcd81d
362b517
c917350
ad262bc
23b8a04
7228df2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4815,6 +4815,24 @@ def test_repr_unicode(self): | |
result = repr(df) | ||
self.assertEqual(result.split('\n')[0].rstrip(), ex_top) | ||
|
||
def test_str_max_colwidth(self): | ||
# GH 7856 | ||
curr_max_colwidth = pd.get_option('max_colwidth') | ||
|
||
# As we change a global option, we save it | ||
|
||
df = pd.DataFrame([{'a': 'foo', 'b': 'bar', | ||
'c': 'uncomfortably long line with lots of stuff', | ||
'd': 1}, | ||
{'a': 'foo', 'b': 'bar', 'c': 'stuff', 'd': 1}]) | ||
df.set_index(['a', 'b', 'c']) | ||
assert(str(df) == ' a b c d\n' | ||
|
||
'0 foo bar uncomfortably long line with lots of stuff 1\n' | ||
'1 foo bar stuff 1') | ||
pd.set_option('max_colwidth', 20) | ||
assert(str(df) == ' a b c d\n' | ||
'0 foo bar uncomfortably lo... 1\n' | ||
'1 foo bar stuff 1') | ||
pd.set_option('max_colwidth', curr_max_colwidth) | ||
|
||
def test_unicode_string_with_unicode(self): | ||
df = DataFrame({'A': [u("\u05d0")]}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
with pd.option_context('max_colwidth',.....):
so that it will only affect the code you want it to