
图a
(1)统计各个区域超全国总消费平均值的省份数量,请在划线处填入合适的代码。
import pandas as pd
plt. rcParams["font.sans-serif"]=["SimHei"]
df=pd.read_excel ("xiaofei.xlsx")
df[ ①
avg=df.总消费.mean ()
dic={"华北":0,"东北":0,"华东":0,"华中":0,"华南":0,"西南":0,"西北":0}
for i in ②
if df.总消费[i]>=avg:
dic[ ③
(2)若要筛选出总消费最高的5个省份,程序划线④处的代码为
res= ④
print ("总消费最高的5个省份为:\n",list (res.省份))
A.df.sort_values("总消费",ascending=False).head (5)
B.df.sort_values ("总消费"). tail (5)
C.df.sort_values ("总消费") [0:5]
D.df.sort_values ("总消费",ascending=False)[0:5]
(3)统计并绘制2022年各区域总消费平均值比较图,如图b所示。部分Python程序如下,请在划线处填入合适的代码。

图b
import matplotlib. pyplot as plt
df1=df. groupby ("区域",as_index=True).mean ()
plt. bar ( ⑤
plt. title ("全国各区域总消费平均值比较图")
plt. ylim (20000,36000)
plt. show ()

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

