2
我的代碼(從書Python Data Science Handbook(O'Reilly出版)):錯誤=真
披露:在寫作的時候,這本書仍處於早期發佈,這意味着它仍然未經編輯並且處於原始狀態。
import numpy as np
import pandas as pd
import seaborn as sns
titanic = sns.load_dataset('titanic')
titanic.pivot_table('survived', index='sex', columns='class')
結果是:
但是,如果我現在嘗試添加使用margins
關鍵字總數,出現以下錯誤:
titanic.pivot_table('survived', index='sex', columns='class', margins=True)
TypeError: cannot insert an item into a CategoricalIndex that is not already an existing category
任何想法可能造成這種情況?
版本信息:
- 的Python 3.4.2
- 大熊貓0.16.2
- numpy的1.9.2
這看起來像熊貓給我的錯誤。 –
對於它的價值,它可以很好的使用python 2.7.10中的熊貓0.14.1和0.16.2 – Alexander