1

Default behavior will hide longer content, but would like to show long field content with line wrap.

import pandas as pd

data = [[11,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],[1,"a"],[1113,"aa"],[1,"aaaa"]]
df = pd.DataFrame(data,columns=["x","y"])

pd.set_option('display.max_colwidth',20)
print(df)

result:

:       x                    y
: 0    11  aaaaaaaaaaaaaaaa...
: 1     1                    a
: 2  1113                   aa
: 3     1                 aaaa

expected:

:       x                    y
: 0    11  aaaaaaaaaaaaaaaaaaa
           aaaaaaaaaaaaaaaaaaa
           aaaaa
: 1     1                    a
: 2  1113                   aa
: 3     1                 aaaa
Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
beetlej
  • 1,841
  • 4
  • 13
  • 27
  • 1
    Does this answer your question? [Pandas DataFrames: how to wrap text with no whitespace](https://stackoverflow.com/questions/34376896/pandas-dataframes-how-to-wrap-text-with-no-whitespace) – Emma Jul 20 '22 at 14:55

0 Answers0