Skip to content

Commit f62f48d

Browse files
committed
update Day14's homework
1 parent 8f493e0 commit f62f48d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

D14_Pivot/homework.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
# 題目:運用分數資料重新建構資料,將索引(index)依序改為 sex、class、student_id,
77
# 欄位依序改成chinese_score、english_score、math_score
8-
score_df.set_index('sex')
9-
print(score_df)
8+
newlist = score_df.melt(id_vars=['sex','class','student_id'])
9+
print(newlist)
10+
print( newlist.pivot(index=['sex','class','student_id'], columns='variable', values='value') )

0 commit comments

Comments
 (0)