图 a | 图 b |
统计全年每月降水天数(当日总降水量大于 0 即计入降水天数),编写 Python 程序,回答下列问题:
import pandas as pd
df=pd.read_excel ("weather.xlsx")
df1=
print(df1)
A. df.groupby("降水量",as_index= True). 日期.sum() B. df.groupby("降水量",as_index=False). 日期.sum() C. df.groupby("日期",as_index=False).降水量.sum() D. df.groupby("日期",as_index=True).降水量.sum()import matplotlib.pyplot as plt
plt.rcParams['font.family']='SimHei' #设置图表中的中文字体
days=[31,28,31,30,31,30,31,31,30,31,30,31] #2022 年每月天数
rain_days=[0]*12
begin=0
for m in range(12):
for d in range(begin, ):
if df1.at[d,"降水量"]>0:
begin+=days[m]
x=[i+1 for i in range(12)]
y=rain_days
plt.bar ( , label="降水天数") plt.xticks(x) #设置横坐标刻度
plt.legend()
plt.show ()
图 c