3

I was trying to convert dictionary to pandas dataframe. I have pretty long string in the original dictionary but when I convert into dataframe, I see these strings get shortened. Do anyone know how to store whole string in the dataframe?

Here is some code:

To convert into Dataframe

test = pd.DataFrame(res['Items'][-1]['Item']) 

Whole string code from dictionary

res['Items'][-1]['Item']['catchcopy'] 

Output:

'クリスタルガイザー / クリスタルガイザー(Crystal Geyser) / ミネラルウォーター 500ml 48本 水 ケース☆送料無料☆' 

Shortened string code from dataframe

test.catchcopy 

Output:

0 クリスタルガイザー / クリスタルガイザー(Crystal Geyser) / ミネラルウォ... Name: catchcopy, dtype: object 
3
  • Consider to create a Minimal, Complete, and Verifiable example Commented Feb 5, 2016 at 5:32
  • please provide sample of dict, panda and your code used to convert it Commented Feb 5, 2016 at 5:33
  • Thanks, I added some code in the question. Commented Feb 5, 2016 at 5:38

1 Answer 1

13

You seem to be confusing the content of the pandas cell with its display. If you want to change the latter, try using display.max_colwidth, like so:

pd.set_option('max_colwidth',40) 

Also, if your DataFrame is df and the column name is 'c', you can access the contents of a cell using:

df['c'].values[1] 

(for the second cell, e.g.). If you print this, for example, you should see your Python interpreter's rendition of the string.

Sign up to request clarification or add additional context in comments.

4 Comments

Oh I see, thanks Ami. If you want to temporarily display entire string of a certain cell, how would you do it? Or is it possible?
@user3368526 See update.
Great, worked :D Thank you!
You're very welcome.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.