11

I have a data frame with one column which contains long text descriptions.

I would like to display all the text without truncating it, but in a manner in which the column makes wider instead of making the row higher.


If I let pandas' default settings, I get next:

enter image description here


But if I try to remove truncate using pd.set_option('display.max_colwidth', -1), the row gets higher while row width mantains almost equal:

enter image description here

3
  • 2
    When I try it in my notebook, the column actually gets wider with the command pd.set_option('max_colwidth', -1) but also the row gets higher because I choose a very long text Commented May 18, 2019 at 10:26
  • 1
    setting -1 returns ValueError: Value must be a nonnegative integer or None in pandas 1.0.0 why? is -1 deprecated. I want to have the behaviour of -1 screenshot above. how? Commented Feb 4, 2020 at 8:18
  • 3
    @ihightower: yes, I believe -1 is deprecated as of pandas 1.0.0. But pd.set_option('max_colwidth', None) should give the same result Commented Apr 29, 2021 at 14:48

1 Answer 1

10

Use the below setting to change only for 1 column.

df.style.set_properties(subset=['ad_description'], **{'width-min': '300px'}) 

Edits: @Haritz Laboa: Thanks for confirming that 'width-min' works and not 'width'.

Sign up to request clarification or add additional context in comments.

4 Comments

Maybe I'm doing something wrong, but it doesn't work for me. Thanks anyway
I figured out that it works only if I use width-min instead of width. Change your answer and I'ill mark it as answered. Thanks ;)
I get: KeyError: 'Styler.apply' and '.applymap' are not compatible with non-unique index or columns.'
I am getting this error Error in parse(text = x, srcfile = src): <text>:1:32: unexpected '[' 1: df.style.set_properties(subset=[ ^

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.