This is for pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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