Khris
Khris

Reputation: 3212

How to output a long dictionary in a pandas dataframe column in its entirety?

I have a pandas dataframe with rather long dictionaries in one column.

Example:

import pandas as pd
D = [[{'a':'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','b':'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}]]
df = pd.DataFrame.from_dict(D)
print df[0]

Which leads to this output:

0    {u'a': u'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', u'...
Name: 0, dtype: object

Everything but the start of the dictionary is omitted with ellipses.

How do I output the full dictionary without iterating over the individual keys?

Upvotes: 0

Views: 645

Answers (2)

Subin Gopi
Subin Gopi

Reputation: 561

D = [[{'a':'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','b':'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}]]
print D[0][0]

Upvotes: 0

shivsn
shivsn

Reputation: 7838

this should work:

In[6]:df[0].values
Out[6]: array([ {'a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'b': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}], dtype=object)

Upvotes: 1

Related Questions