Back to TILs.

Calmcode TIL

Pandas Column Width logoPandas Column Width

When you deal with text in .csv files then you may have noticed that pandas truncates this so that a dataframe may fit on screen. That means that the text may look something like:

69993 See her recent article in The Atlantic ...
69994 Before we continue, I would first like ...
69996 This is great! Can anyone make a reques ...
69997 I’m sorry. Can you please explain what ...
69998 No but it should be

It shows text, but it gets truncated.

Setting Options

To prevent this, you can use the pd.set_option method to set the column width.

import pandas as pd

pd.set_option('display.max_colwidth', None)

After doing this, all the text is displayed again.

Back to TILs.