0
import pandas as pd
from string import ascii_letters as al
from random import choice

data = [[''.join([choice(al) for x in range(100)]),'2']] #generating 100 long string of charachter


label = ['text', 'number']

x = pd.DataFrame.from_records(data=data,columns=label)

print(x)

If you print x, you will see pandas Dataframe shortens value by adding "...".

0  ZguBjqdVeKzyzcaBZeufeRCIEDQJRYeinDRWSaLDbrezZN...      2

Is there a way in pandas to see long words in full? By making larger "cell size" or something. Would appreciate your help. I have already tried something with set.option, however no results...

using:

with pd.option_context('display.max_colwidth', -1):
    x = pd.DataFrame.from_records(data=a,columns=b)
    print(x)

I get whole word, but the number column is then being placed in other row. It's not printable at all. I am looking something like merge cell option in excel.

Thank you.

EDITED:

Solution is:

with pd.option_context('display.height',-1, 'max_colwidth', -1):


    x = pd.DataFrame.from_records(data=a,columns=b)

    print(x.to_string())
    a = input()
Makaroniiii
  • 308
  • 2
  • 16
  • @EdChum ... Mister, funny guy. Before marking as duplicate, read the question first, run the code, read the question again and then start witch hunting on duplicates. If there would be a duplicate, I would already find it... Do you think I don't google? – Makaroniiii Aug 23 '17 at 13:46
  • You edited the question after I marked it as duplicate, in your original post you simply stated *tried something with set.option* but not what you tried. You've now updated the question to state you also want to see more columns which is different, besides did you try https://stackoverflow.com/questions/11707586/python-pandas-how-to-widen-output-display-to-see-more-columns also? If those answers are not duplicates then indicate why – EdChum Aug 23 '17 at 13:50
  • @EdChum I didn't edit it because of you, I edited it because I had a need to explain something... I can handle my questions on my own. I use google and I can edit it bymyslef. And perhaps I will edit it even more. Who knows. – Makaroniiii Aug 23 '17 at 13:53
  • @EdChum O.K. I apologize. I have check the link again, you proposed and I found a solution for my question. Indeed it is a duplicate. Thank you very much and once again, please accept my apology. – Makaroniiii Aug 23 '17 at 14:01
  • Apology accepted, dupe voting isn't a punishment, also I didn't down vote, and don't assume intentions on SO. If you feel it's not a dupe then it can be voted to be reopened after clarification, or the original voter can reopen, it's important to be clear in your question about what you're after, what you tried and researched. – EdChum Aug 23 '17 at 14:05
  • I know you didn't downvote, if you would want to, you would do it earlier. All the best. – Makaroniiii Aug 23 '17 at 14:07

1 Answers1

1

From the documentation:

display.max_colwidth sets the maximum width of columns. Cells of this length or longer will be truncated with an ellipsis.

pd.set_option('max_colwidth', 40)
Steven Laan
  • 180
  • 10