圖 a | 圖 b |
import pandas as pd
import matplotlib.pyplot as plt
#讀取如圖 b 所示數(shù)據(jù),保存到 DataFrame 對象 df1 中,代碼略
f = [9, 7, 6, 5, 4, 3, 2, 1]
for i in range(0,len(dfl)):
rank = df1.at[i,"名次"] #通過行、列標(biāo)簽取單個(gè)值
score = 0
if rank <= 8:
df1.at[i,"得分"] = score
df2 = dfl.groupby(" ▲ ",as_index=False).sum() #分組求和
#設(shè)置繪圖參數(shù),代碼略
plt.bar(x,y) #繪制柱形圖
①請?jiān)诔绦蛑袆澗€處填入合適的代碼。
②程序的方框中應(yīng)填入的正確代碼為 (單選,填字母)
A.x = df1["專業(yè)"]
y = df1["總分"]
B.x = df2["專業(yè)"]
y = df2["得分"]
C.df1["專業(yè)"] = "專業(yè)"
df1["總分"] = "總分"
D.Df2["專業(yè)"] = "專業(yè)"
Df2["得分"] = "得分"