I have a set of data in a list. Each item of the list is a dictionary with a unique key and the value of the dictionary is a DataFrame that contains 6 columns + index col.
list = [{"A": Participation Assignment Words Creativeness Innovative Great
Date
2021-01-02 95.00 75.00 75.00 79.00 100 OK
2021-01-05 83.00 83.00 83.00 80.00 100 OK
2021-01-06 98.88 78.88 77.00 77.00 34 OK
2021-01-07 77.00 77.00 77.00 77.00 150 OK
2021-01-08 79.00 79.00 70.00 70.00 99 OK
... ... ... ... ... ... ...
2021-02-18 65.67 36.67 35.59 36.88 94 OK
2021-02-19 60.94 38.00 36.94 38.72 75 OK
2021-02-22 40.00 43.80 40.80 42.71 82 OK
2021-02-23 42.00 43.81 38.99 42.29 174 OK
2021-02-24 42.00 45.00 42.00 44.17 175 OK
[1065 rows x 6 columns]}, "B": Participation Assignment Words Creativeness Innovative Great
Date
2021-01-02 95.00 75.00 75.00 79.00 100 OK
2021-01-05 83.00 83.00 83.00 80.00 100 OK
2021-01-06 98.88 78.88 77.00 77.00 340 OK
2021-01-07 77.00 77.00 77.00 77.00 150 OK
2021-01-08 79.00 79.00 70.00 70.00 93 OK
... ... ... ... ... ... ...
2021-02-18 65.67 36.67 35.59 36.88 94 OK
2021-02-19 60.94 38.00 36.94 38.72 95 OK
2021-02-22 40.00 43.80 40.80 42.71 182 OK
2021-02-23 42.00 43.81 38.99 42.29 174 OK
2021-02-24 42.00 45.00 42.00 44.17 75 OK
[1065 rows x 6 columns]}, ...]
What I want to do is to have a large DataFrame where the general index is the Date, the first index Column is the respective key of each dictionary and the sub index of this is
A B
Participation Assignment Words Creativeness Innovative Great Participation Assignment Words Creativeness Innovative Great
Date
2021-01-02 95.00 75.00 75.00 79.00 100 OK 95.00 75.00 75.00 79.00 100 OK
Something like that. Is it possible?
First dont use variable list
, because python code word ( builtin
).
You can use concat
, with dictionary is created MultiIndex
from keys of dicts:
df = pd.concat(L, axis=1)
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.