I have a DataSet in the Following Format coming from a rester Service
{'C': {('x', 'Active'): 1, ('x', 'Ready'): 1, ('y', 'Active'): 1, ('y', 'Ready'): 1, ('z', 'Active'): 1, ('z', 'Ready'): 2}}
and the Excepted Out I Want is
But when i try to load data in DF it Loads the Key ie (Row,Column) as Index
You can do:
pd.Series(data['C']).unstack()
Output:
Active Ready
x 1 1
y 1 1
z 1 2
Another way; Apply pd.DataFrame and drop multiindex columns
df=pd.DataFrame(data).unstack()
df.columns=df.columns.droplevel()
Active Ready
x 1 1
y 1 1
z 1 2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.