Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Created Mar 11, 2020
Embed
What would you like to do?
This is for pandas
import pandas as pd
#
data = pd.DataFrame({
"name":["Amy", "Bob", "Chole"],
"score":[100, 80, 69]
})
#1.計算三位學生的成績平均值
score = data["score"]
print("成績平均值:", score.mean())
#2.在欄位中新增一欄,內容為學生的操行成績
data["grade"] = ["C", "A", "B+"]
print(data)
#打印出
"""
成績平均值: 83.0
name score grade
0 Amy 100 C
1 Bob 80 A
2 Chole 69 B+
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment