Reputation: 16488
I understand that pandas does cut-off long elements. However, why does it do that in the html output?
import pandas as pd
df = pd.DataFrame(columns=['url'], index=[0])
df['url'] = 'd12dn1928d1n298dn18d9n219d8n18n118219d8n21e12903e21kj9012j9301j2391023j209d12dn1928d1n298dn18d9n219d8n18n118219d8n21e12903e21kj9012j9301j2391023j209d12dn1928d1n298dn18d9n219d8n18n118219d8n21e12903e21kj9012j9301j2391023j209d12dn1928d1n298dn18d9n219d8n18n118219d8n21e12903e21kj9012j9301j2391023j209d12dn1928d1n298dn18d9n219d8n18n118219d8n21e12903e21kj9012j9301j2391023j209'
In [2]: df
Out[2]:
url
0 d12dn1928d1n298dn18d9n219d8n18n118219d8n21e129...
In [3]: df.to_html()
Out[3]: u'<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>url</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>d12dn1928d1n298dn18d9n219d8n18n118219d8n21e129...</td>\n </tr>\n </tbody>\n</table>'
even in the html output (where it is obvious that it won't fit the screen width), the column value is truncated. How can I force pandas
to not truncate, both with and without html?
Upvotes: 21
Views: 20227
Reputation: 2807
You can turn off the truncating display option with:
pd.set_option('display.max_colwidth', None)
or before Pandas 1.0,
pd.set_option('display.max_colwidth', -1)
Upvotes: 33
Reputation: 226
As an update, instead of
pd.set_option('display.max_colwidth', -1)
you should now use
pd.set_option('display.max_colwidth', None)
Upvotes: 2