1
时,我发现这种行为在熊猫我在下面这个blogpost:意外的输出与熊猫pivot_tables
df = pd.read_csv("http://www.ats.ucla.edu/stat/data/binary.csv")
df.columns = ["admit", "gre", "gpa", "prestige"]
pd.pivot_table(df,values='admit',rows=['admit'], cols=['prestige'],aggfunc='count')
TypeError: 'DataFrame' object is not callable
而是,如果你指的是行和列df['admit'], df['prestige']
,你会得到预期的结果:
pd.pivot_table(df,values='admit',rows=df['admit'], cols=df['prestige'],aggfunc='count')
prestige 1 2 3 4
admit
0 28 97 93 55
1 33 54 28 12
根据文档,我应该只能使用列名或列中的列名来引用DataFrame。这是一个错误还是我错过了什么?
感谢。是的,这是更合理的,但文件说,我应该能够使用列表和数组。 – 2013-05-14 18:57:25
不客气。我认为大熊猫在“价值”和“行”中都被“承认”所困惑,但没有深入研究。 – Garrett 2013-05-14 20:58:38