Given the following dataset:
"";"M_001";"M_002";"M_003";"M_004"
"2011-01-01 00:00:00";4,45;3,5467;3,197;12,098
"2011-02-01 00:00:00";18,40;0,124;174,36;11,098
"2011-03-01 00:00:00";25,789;27,67;19,76;34,66
"2011-04-01 00:00:00";19,08;11,078;23,34;67,45
"2011-05-01 00:00:00";13,06;06,078;10,34;21,45
"2011-06-01 00:00:00";13,06;06,078;10,34;21,45
"2011-06-21 00:00:00";13,06;06,078;10,34;21,45
"2011-07-01 00:00:00";9,06;06,078;9,34;21,45
"2011-07-14 00:00:00";9,06;06,078;9,34;21,45
"2011-08-01 00:00:00";22,06;45,078;21,34;21,45
"2011-08-11 00:00:00";22,06;45,078;21,34;21,45
"2011-08-12 00:00:00";22,06;45,078;21,34;21,45
"2011-09-01 00:00:00";76,06;32,078;10,34;21,45
"2011-09-23 00:00:00";76,06;32,078;10,34;21,45
"2011-09-25 00:00:00";76,06;32,078;10,34;21,45
"2011-10-01 00:00:00";17,06;18,078;108,34;21,45
"2011-11-01 00:00:00";12,06;45,078;107,34;21,45
"2011-12-01 00:00:00";7,06;60,078;83,34;21,45
"2011-12-21 00:00:00";7,06;60,078;83,34;21,45
"2012-01-01 00:00:00";4,45;3,5467;3,197;12,098
"2012-02-01 00:00:00";18,40;0,124;174,36;11,098
"2012-03-01 00:00:00";25,789;27,67;19,76;34,66
"2012-03-11 00:00:00";25,789;27,67;19,76;34,66
"2012-03-20 00:00:00";25,789;27,67;19,76;34,66
"2012-03-30 00:00:00";25,789;27,67;19,76;34,66
Could anyone tell me how to modify the function calc() to select the rows from the dataset in order that I can get separately the rows about both the winter season (from 21 december to 20 march) and the summer season (from 21 june to 23 september) from read_csv?
I have already tried on writing this code, but it doesn't work well.
import pandas as pd
def calc():
filename = 'mydataset/dataset.csv'
mySeries = pd.read_csv(filename, header=0, index_col=0, parse_dates=[0], sep=";", decimal=",")
return mySeries
if __name__ == '__main__':
df = calc()
print("Winter season measures: ")
print(df.iloc[[x in range(12, 3) for x in df.index.month]])
print("Winter season measures: ")
print(df.iloc[[x in range(6, 10) for x in df.index.month]])
Thank you in advance!