Reputation: 13
Date_A Date_B Date_C Amount
0 09/01/2016 09/01/2016 01/01/1800 2405814.36
1 09/01/2016 09/01/2016 09/01/2016 11347445.71
2 09/01/2016 10/01/2016 01/01/1800 5005106.94
3 09/01/2016 10/01/2016 09/02/2016 391679.95
4 09/01/2016 10/01/2016 10/01/2016 15982401.76
5 09/01/2016 11/01/2016 01/01/1800 3625649.29
6 09/01/2016 11/01/2016 10/14/2016 200730.30
7 09/01/2016 11/01/2016 11/01/2016 3801867.77
8 09/01/2016 01/01/2017 01/01/2017 398961.22
9 10/01/2016 10/01/2016 01/01/1800 1357447.92
10 10/01/2016 10/01/2016 10/01/2016 12365703.34
11 10/01/2016 11/01/2016 01/01/1800 2783979.14
12 10/01/2016 11/01/2016 10/21/2016 67891.65
13 10/01/2016 11/01/2016 11/01/2016 10863491.98
14 10/01/2016 12/01/2016 01/01/1800 1005897.36
15 10/01/2016 12/01/2016 12/01/2016 1757775.53
16 10/01/2016 01/01/2017 01/01/1800 394251.89
17 10/01/2016 01/01/2017 12/09/2016 518831.09
18 10/01/2016 02/01/2017 02/01/2017 29021.55
19 11/01/2016 11/01/2016 01/01/1800 16732269.88
20 11/01/2016 11/01/2016 11/01/2016 24903566.09
21 11/01/2016 12/01/2016 01/01/1800 19229021.72
22 11/01/2016 12/01/2016 12/01/2016 16198633.56
23 11/01/2016 12/01/2016 12/20/2016 119524.82
24 11/01/2016 01/01/2017 01/01/1800 8032009.03
25 11/01/2016 01/01/2017 01/01/2017 1407168.25
26 11/01/2016 02/01/2017 02/01/2017 350913.09
27 12/01/2016 12/01/2016 01/01/1800 11399137.45
28 12/01/2016 12/01/2016 12/01/2016 10973693.60
29 12/01/2016 12/01/2016 12/06/2016 144625.55
30 12/01/2016 12/09/2016 12/09/2016 134749.29
31 12/01/2016 12/16/2016 12/16/2016 325738.94
32 12/01/2016 01/01/2017 01/01/1800 12583630.38
33 12/01/2016 01/01/2017 01/01/2017 16438291.27
34 12/01/2016 02/01/2017 01/01/1800 6681684.58
35 12/01/2016 02/01/2017 02/01/2017 1367619.74
36 01/01/2017 01/01/2017 01/01/1800 5220981.26
37 01/01/2017 01/01/2017 01/01/2017 13408941.99
38 01/01/2017 02/01/2017 01/01/1800 4085550.81
39 01/01/2017 02/01/2017 02/01/2017 11957184.41
40 01/01/2017 03/01/2017 01/01/1800 203253.80
41 02/01/2017 02/01/2017 01/01/1800 6027172.13
42 02/01/2017 02/01/2017 02/01/2017 6795843.54
43 02/01/2017 03/01/2017 01/01/1800 197842.86
This is the original dataframe which has to be divided into 6 dataframes by performing group by on Date_A. The result should output 6 dataframes with Date_A values being 09/01/2016
,10/01/2016
,11/01/2016
,12/01/2016
,01/01/2017
and 02/01/2017
.
Upvotes: 1
Views: 1085
Reputation: 862591
You can use groupby
for create dictionary
of DataFrames
:
d = dict(tuple(df.groupby('Date_A')))
print (d['09/01/2016'])
Date_A Date_B Date_C Amount
0 09/01/2016 09/01/2016 01/01/1800 2405814.36
1 09/01/2016 09/01/2016 09/01/2016 11347445.71
2 09/01/2016 10/01/2016 01/01/1800 5005106.94
3 09/01/2016 10/01/2016 09/02/2016 391679.95
4 09/01/2016 10/01/2016 10/01/2016 15982401.76
5 09/01/2016 11/01/2016 01/01/1800 3625649.29
6 09/01/2016 11/01/2016 10/14/2016 200730.30
7 09/01/2016 11/01/2016 11/01/2016 3801867.77
8 09/01/2016 01/01/2017 01/01/2017 398961.22
EDIT:
For looping use items()
:
for i, df in d.items():
print (i)
print (df)
Upvotes: 1