I have a pandas dataframe with two columns - one for id and other for the corresponding title. I am subsetting the dataframe for a few project ids and displaying the resulting dataframe. On doing so, the project id gets displayed fine but the corresponding title gets truncated and end with ...
after a few characters, How do I get pandas to display the full text in the title column?
Asked
Active
Viewed 5,859 times
2

Clock Slave
- 7,627
- 15
- 68
- 109
-
1check `display.max_colwidth` in [docs](http://pandas.pydata.org/pandas-docs/stable/options.html#frequently-used-options) (`In [44]:`) – jezrael Mar 01 '17 at 13:20
-
@EdChum not exactly I think. That issue was when the OP had multiple columns and pandas decided to omit a few of them while printing. In my case there's only two columns both of which are getting printed but one gets truncated – Clock Slave Mar 01 '17 at 13:26
-
1then this is more appropriate http://stackoverflow.com/questions/26277757/pandas-to-html-truncates-string-contents/26301947#26301947 – EdChum Mar 01 '17 at 13:29
1 Answers
6
You can use display.max_colwidth
:
df = pd.DataFrame(np.array([[1,'aaa'],
[2, 'long string long string long string long string long string']]), columns=['id','title'])
print (df)
id title
0 1 aaa
1 2 long string long string long string long strin...
#temporaly display long text
with pd.option_context('display.max_colwidth', 100):
print (df)
id title
0 1 aaa
1 2 long string long string long string long string long string

jezrael
- 822,522
- 95
- 1,334
- 1,252