Skip to content Skip to sidebar Skip to footer

How To Output To Dict Type In Pandas

I have the following data, and I would like to output it in a dict type, but after trying various ways, I get an error, so I asked this question. s 'report': [ 999,

Solution 1:

I think it's better to do it using pandas: test = s.to_dict()

You could also do:

test = dict(zip(str(s.index), s))

or

test = {x : y for x, y in zip(str(s.index), s)}

or

test = {str(s.index[i]) : s[i] for i in range(len(s))}

Post a Comment for "How To Output To Dict Type In Pandas"