Reputation: 91
I have a simple data frame in Pandas
0 2020-12-03 12:00:00 122.219985 122.798140 121.821258 122.703443 9204466
1 2020-12-03 13:00:00 122.708427 122.838013 122.349572 122.494111 6596303
2 2020-12-03 14:00:00 122.489226 122.638649 122.205033 122.269826 5510204
3 2020-12-04 10:00:00 122.359540 122.469988 121.153389 121.681703 12470960
4 2020-12-04 11:00:00 121.671735 121.791353 121.133453 121.402594 11617192
5 2020-12-04 12:00:00 121.400799 122.274810 121.233134 121.983540 8799353
.......
The date column called Datetime
, and i am trying to split this data frame into array of dataframes where each element is a dataframe
of a single day, with indexes starting from 0.
array = [df0,df1,..]
df0 :
0 2020-12-03 12:00:00 122.219985 122.798140 121.821258 122.703443 9204466
1 2020-12-03 13:00:00 122.708427 122.838013 122.349572 122.494111 6596303
...
df1:
0 2020-12-04 10:00:00 122.359540 122.469988 121.153389 121.681703 12470960
1 2020-12-04 11:00:00 121.671735 121.791353 121.133453 121.402594 11617192
....
Upvotes: 1
Views: 345
Reputation: 323326
Try with
d = {x: y for x , y in df.groupby(df['yourdate'].dt.date)}
Upvotes: 3