
要分析某商品一个月内的价格稳定情况,需要将本月每天(除第一天外)价格波动的绝对值加起来(价格波动=当天价格

为统计该超市6月份各商品价格稳定情况,编写如下Python程序。请回答下列问题:
import pandas as pd
df=pd.read_excel("data.xlsx")
df=
df=df. reset_index(drop=True) #重新设置索引,从0开始递增
(1)获取6月份各商品的价格,划线处填入的代码为
A. df[df["日期"]>=20220601] B. df["日期">=20220601]
C. df[df.日期>=20220601] D. df[df["日期"]]>=20220601
(2)绘制6月份价格稳定情况线形图,部分Python程序如下,请在划线处填入合适的代码。

import matplotlib. pyplot as plt
cols=df. columns[1:]#存储各商品名称
n=
m=len(cols)
diff=[0]*m
for i in range(m):
s=0
for j in range(1,n):
day_diff=abs(df[cols[i]][j]-df[cols[i]][j-1]) #计算每天价格波动
s+=day_diff
x,y=cols, diff
plt
plt. show()
(3)由图b可知,该超市6月份各商品价格最稳定的是
A.商品A B.商品B C.商品C D.商品D E.商品E

同类型试题

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

