Skip to content

Commit 96e9bf7

Browse files
committed
update example trials
1 parent 0bca0a8 commit 96e9bf7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

D13_apply/homework.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@
2323
print(newscore.values[5])
2424

2525
# 承上題,加分後各科班平均變多少
26-
print('加分後各科班平均變多少 \n%s' % newscore.mean())
26+
print('加分後各科班平均變多少 \n%s' % newscore.mean())
27+
28+
# 範例程式臨摹
29+
print('--------------------------')
30+
Exdf = pd.DataFrame([[1,56,66,70], [2,90,45,34], [3,45,32,55], [4,70,77,89], [5,56,80,70], [6,60,54,55], [7,45,70,79], [8,34,77,76], [9,25,87,60], [10,88,40,43]],columns=['student_id','math_score','english_score','chinese_score'])
31+
Exdf = Exdf.set_index('student_id')
32+
33+
print(Exdf.mean(axis=1)[6])
34+
print(Exdf.mean(axis=1).median())
35+
print(Exdf.apply(lambda x: x**(0.5)*10))
36+
print(Exdf.apply(lambda x: x**(0.5)*10).values[5]) #values uses old index rule

0 commit comments

Comments
 (0)