開始使用免費開始

解碼密訊

你在書籍專案上表現很棒!你的主管鼓勵你用 Dan Brown 的著作做一個分析。

你已經探索過資料集 books_brown,發現需要重新塑形。你再次找出了幾個欄位可作為唯一 ID,並注意到要分組的欄位有些不同。它們的名稱有共同的前綴,不過這次你還辨識出一個後綴和分隔符號。

books_brown 資料集已為你準備好。它包含每本書的 titleauthor,以及 language_codelanguage_namepublisher_codepublisher_name 等資料。請務必在主控台檢視它!

本練習屬於課程

使用 pandas 重塑資料

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Reshape using author and title as index, code as new name and getting the prefix language and publisher
the_code_long = pd.wide_to_long(____, 
                                ____=____, 
                                ____=____, 
                                ____=____)

# Print the_code_long
print(the_code_long)
編輯並執行程式碼