I am learning Pandas and am hitting a wall creating a dataFrame from the following input:
tracked = {
'Created': (df1.count()['Created']),
'Closed': (df1.count()['Closed']),
'Owner': (df1['Owner'].value_counts().to_dict()),
'Resolution': (df1['Resolution'].value_counts().to_dict()),
'Severity': (df1['Severity'].value_counts().to_dict())
}
which creates:
pp.pprint(tracked)
{u'Closed': '11', #numpy
u'Created': '42', #numpy
u'Owner': {u'foo.bar': 3, #dict
u'FooBar': 6,
u'BarFoo': 30,
u'bar.foo': 3},
u'Resolution': {u'FalsePositive': 1, u'TruePositive': 10}, #dict
u'Severity': {1: 7, 2: 31, 3: 4}} #dict
my current DataFrame
df4 = pd.DataFrame.from_dict({(i): tracked[i]
for i in tracked.keys()},
orient='index').transpose()
which creates:
pp.pprint(df4)
Owner Resolution Severity Closed Created
0 {u'foobar': 30, u'foo.bar': 3, u'bar.f... {u'FalsePositive': 1, u'TruePositive': 10} {1: 7, 2: 31, 3: 4} 11 42
my desired output would expand the dicts for Owner, Resolution and Severity over columns or rows.
I have tried a number of SO/Web solutions including trying to flatten the dict which returns a AttributeError: 'int' object has no attribute 'split'.
Any help would be greatly appreciated.