I want to use Pandas and Python to iterate through my .csv file and group the data by season, calculating the average for each season of the year. Currently, the quarterly script does Jan-Mar, April-June, etc. I want the seasons to correspond to the months - 11: "Winter", 12: "Winter", 1: "Winter", 2: "Spring", 3: 'Spring', 4: 'Spring', 5: 'Summer', 6: 'Summer', 7: 'Summer', \ 8: “Autumn”, 9: “Autumn”, 10: “Autumn”
I have the following data:
Date,HAD 01/01/1951,1 02/01/1951,-0.13161201 03/01/1951,-0.271796132 04/01/1951,-0.258977158 05/01/1951,-0.198823057 06/01/1951,0.167794502 07/01/1951,0.046093808 08/01/1951,-0.122396694 09/01/1951,-0.121824587 10/01/1951,-0.013002463
This is my code:
# Iterate through a list of files in a folder looking for .csv files for csvfilename in glob.glob("C:/Users/n-jones/testdir/output/*.csv"):
Hope this makes sense.
Thank you in advance!
source share