Home > Net >  Python pandas how to transform defaultdict to csv format?
Python pandas how to transform defaultdict to csv format?

Time:11-10

So I have data that will appear in this format:

defaultdict(<class 'list'>, {'ZY20': [545, 27, 402], 'ZYV0': [2190, 5,
> 78], 'ZZL0': [175, 21, 90]})

I want to take this data and parse it to look like this:

ZY20 545 27 402
ZYV0 2190 5 78
ZZL0 175 21 90

What is the appropriate pandas data frame call to be able to do this? The normal Dataframe call to this type of array does not provide the format I'm looking for in csv format?

Thanks

CodePudding user response:

You can do

out = pd.DataFrame.from_dict(d,'index')
Out[23]: 
         0   1    2
ZY20   545  27  402
ZYV0  2190   5   78
ZZL0   175  21   90
  • Related