图 a |
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_excel("浙江 A 级景区.xlsx")
df = df.drop(["电话", "景区编码"], ) # 删除不必要的列
for row in range(len(df)): # 整理“等级”列数据
grade = df.at[row, "等级"]
if '1' <= grade[0] <= '9':
df.at[row, "等级"] = "A" * int(grade[0])
df2 = df[ >= "AAAA"]
dfg = df2.groupby("地市").count()
dfg = dfg.rename(columns={'等级': "数量"}) # 重命名列名称
dfg. ("数量", ascending=False, inplace=True)
图 b |
plt.figure(figsize=(8,4))
plt.rcParams['font.sans-serif']=['SimHei','FangSong']
plt.title("浙江 AAAA 级以上景区数量统计图")
#加框处语句(需补充) |
for i in range(len(dfg)):
plt.text(i, dfg["数量"][i]+1, dfg["数量"][i])
plt.xlabel("地市名称")
plt.ylabel("数量")
plt.legend( )
plt.show ( )
为实现上述功能,则加框处的语句最合适的是( ) (单选,填字母)