I have created a dictionary by grouping some raingauges by their code with this coding
dict_of_gauges = {k: v for k, v in PE_14.groupby('gauge_code')}
which gave me some entries like the ones shown below
11800 261070705A PAULISTA PE 2014-08-21 17:10:00 0.2
11801 261070705A PAULISTA PE 2014-08-21 17:20:00 0.0
11802 261070705A PAULISTA PE 2014-08-21 17:30:00 0.2
11803 261070705A PAULISTA PE 2014-08-21 17:40:00 0.0
11804 261070705A PAULISTA PE 2014-08-21 18:00:00 0.0
[3966 rows x 5 columns],
'261070704A': gauge_code city state datetime rain_mm
11493 261070704A PAULISTA PE 2014-08-21 21:20:00 0.2
11494 261070704A PAULISTA PE 2014-08-21 21:30:00 0.0
11495 261070704A PAULISTA PE 2014-08-21 21:40:00 0.0
11496 261070704A PAULISTA PE 2014-08-21 21:50:00 0.0
11497 261070704A PAULISTA PE 2014-08-21 22:00:00 0.0
[4180 rows x 5 columns],
now i really want to create dataframes for each one of them, and assign names like "df1", "df2" etc... but i dont seem to know how to do that inside a FOR. The code i ended up using was
df1 = pd.DataFrame.from_records(dict_of_gauges['261070703A'])
df2 = pd.DataFrame.from_records(dict_of_gauges['261070705A'])
.
.
.
but its not very professional to do the same thing so many times, i don't know how to assign those names and the pseudocode that i tried to make (below) didnt really work as it was overwriting the "df" at every loop, as expected.
listdfs = ['df0','df1','df2','df3','df4','df5']
for df, gauge in zip(listdfs, dict_of_gauges):
df = pd.DataFrame.from_records(dict_of_gauges[gauge])
Could someone please give me some light in this?