Saturday, 16 November 2019

Divide Dataframe from last 5 months and separate them into 5 different df's from current month?

Divide Dataframe from last 5 months and separate them into 5 different df

have a df that has data from past three years. How to divide the df based on last 5months data into 5 different columns and column names being the month names.

df :

date      amount

2019-08-23 10
2019-06-23 18
2019-07-21 05
2019-09-09 09
2019-09-19 04
2019-08-27 22
2019-05-03 02
2019-06-27 07
2019-05-25 19
2019-04-27 02
2019-01-19 02
2019-05-28 10
2019-02-22 09
2019-01-25 06
2019-10-22 17
2019-11-02 13
2019-10-29 17
2019-03-11 18
2019-03-11 19
2019-10-19 19
2019-02-17 12
2019-10-21 01
2019-09-01 08
2019-01-15 09
2019-11-15 08
2019-10-10 18
2019-03-31 01
2019-08-17 01
2019-05-27 07
2019-02-24 20
2019-11-03 21
2019-06-28 21
2019-01-06 00
2019-03-30 23
2019-06-27 04
2019-03-08 19
2019-01-30 09
2019-11-15 02
2019-06-04 09
2019-05-03 14
2019-07-01 08
2019-09-20 19
2019-05-15 12
2019-05-17 02
2019-09-21 20
2019-02-14 14

Input :

year - 2019 month - 8

Required output

if input is 8 leaving the current month

5 df should be created starting from 7th month to 3rd month

Every time new df should be created .

required df should be :


jul_df:



jun_df:


.
.
.
.
march_df:




from Divide Dataframe from last 5 months and separate them into 5 different df's from current month?

No comments:

Post a Comment