Tuesday, August 21, 2018

Maximum, minimum and average monthly precipitation

Below is shown some panda commands for retrieving maximum, minimum and average monthly precipitation from daily precipitation data.

The daily precipitation is assumed to be in a pandas DataFrame, with its index in Datetime index format.

1 - Daily to monthly precipitation
df_m=df1.resample('M').sum()

2 - Maximum monthly precipitation
p_max=df_m.groupby(df_m.index.month).max()

3 - Minimum monthly precipitation
p_min=df_m.groupby(df_m.index.month).min()

4 - Average monthly precipitation
p_avg=df_m.groupby(df_m.index.month).mean()

2 comments:

  1. Hi, I'm junior hydrologist, just found your blog recently.
    I'm learning python right now, and want you to know that your blog is very helpful.
    I want to ask for this, sometimes there are extreme value in the maximum precip. How to get the 2nd max value to check and normalize the distribution?
    Thank you very much in advance.

    ReplyDelete
  2. Hi, I'm junior hydrologist and I want you to know that your blog is very helpful in my Python coding study.
    I want to ask for this script. Sometimes there are very extreme value in max/min precipitation, how I can use the script to obtain 2nd max/min value, to normalized the distribution or just check is it extreme value or not? Is it possible? Thank you in advance, hope you have great time.

    ReplyDelete