You’re given a dataframe df_rain
containing rainfall data. The dataframe has two columns: day of the week and rainfall in inches.
Write a function median_rainfall
to find the median amount of rainfall for the days on which it rained.
Note: You may assume it rained on at least one of the days.
import pandas as pd
def median_rainfall(df_rain):
# 篩選有下雨的資料
con = df_rain['Inches'] > 0
# 取降雨量的中位數
return df_rain.loc[con]['Inches'].median()
嗨,我是 Eva,一位正在努力跨進資料科學領域的女子!
如果有任何不理解、錯誤或其他方法想分享的話,歡迎留言!
喜歡的話,也歡迎按讚訂閱唷!我們明天見!