I have a dataframe (mydata) that contains more than 10000 samples over 4 three years (from 2016-01-23 to 2019-10-12) including a "date" as one of the features. I want to partition the dataframe (mydata) into 4 dataframes based on the seasons (Spring, Summer, fall and winter). Here is my data frame:
mydata:
f1, f2, f3, date
s1 23, 2.5, 0.3, 2016-04-03
s2 03, 0.5, 1.3, 2017-08-01
s3 14, 4, 2.3, 2016-10-02
....
sn 09, 4.3, 32, 2019-03-03
So me desired output should be four data frames (spring, summer,..). For example, the data which are logged during spring in the four seasons should be placed in the first dataframe (Spring), and so on:
Spring=[the data which are logged during the spring (from march 1 to May 31) during the four years]
Summer=[the data which are logged during the spring (fro June 1 to August 31) during the four years]
.....
I could handle it manually something like this, e.g., for one season, but I want a more efficient way:!
season1=pd.DataFrame()
season1=season1.append(mydata[(mydata['date']>'2016-03-01') & (mydata['date']<'2016-05-31') ])
season1=season1.append(mydata[(mydata['date']>'2017-03-01') & (mydata['date']<'2017-05-31') ])
season1=season1.append(mydata[(mydata['date']>'2018-03-01') & (mydata['date']<'2018-05-31') ])
season1=season1.append(mydata[(mydata['date']>'2019-03-01') & (mydata['date']<'2019-05-31') ])