# How can I see a long string in my dataframe?

I have a column in my dataframe in which there are sentences which are too long. I want to see them as a whole but every time I perform even a simple iloc operation i get output like 'i am going to...'. How can I remove the ... and see the whole sentence ?

At first, here is the Data.

data = {
'Capacity' : [
"qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze",
"qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze",
"qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze",
"qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze"
]
}
df = pd.DataFrame(data)
print(df['Capacity'])
# 0  qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvg...
# 1  qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvg...
# 2  qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvg...
# 3  qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvg...


You can set pd.options.display.max_colwidth to increase the number of characters you want to display.

pd.options.display.max_colwidth = 20
print(df['Capacity'])
# 0    qsfjvanzicgbaefz...
# 1    qsfjvanzicgbaefz...
# 2    qsfjvanzicgbaefz...
# 3    qsfjvanzicgbaefz...

pd.options.display.max_colwidth = 100
print(df['Capacity'])
# 0    qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzb...
# 1    qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzb...
# 2    qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzb...
# 3    qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzb...

# This seeks the maximum length of the current column 'Capacity'.
pd.options.display.max_colwidth = int(df['Capacity'].str.len().max()) + 1
print(df['Capacity'])


Or you can use the .values method instead, so that you are watching the 'raw' data.

#   Reset the option.
pd.options.display.max_colwidth = 50
print(df['Capacity'].values)
# ['qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze'
#  'qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze'
#  'qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze'
#  'qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze']


Or simply select one row from the column you're interested in.

print(df['Capacity'][2])
# qsfjvanzicgbaefzrkrsdvjcfhnefzraezsufchnezsuvgcfnezefzrdfchnzefzreicfjnefzrzekcrghzebefzrkcfjfzbefzrfkjhnvezkqcfhaze


Try it like this:

import pandas as pd

pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
print(df)

New contributor
ASH is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.