Home > OS >  Extract only 1 month from a multi-year netcdf file
Extract only 1 month from a multi-year netcdf file

Time:02-14

I am quite new to programming and I wanted to know if you could help me. I have a file that contains daily precipitation data from 2000 to 2020. I think with pandas I could create a dataframe that contains only the values ​​of the month of January but I can't understand how. Or maybe with CDO create a new file that only contains those values. Could someone help me I would appreciate it

CodePudding user response:

Steps -

  1. Add a month column to your dataframe

df['month']= pd.to_datetime(df['date']).dt.month

  1. Select the rows you want using the condition df.month == 1

df[(df['month'] == 1)]

CodePudding user response:

enter image description here

I have this dataframe but i can´t add a month column

  • Related