Bod*_*de 8 python pivot-table dataframe pandas
我有一个数据框,df,有 646585 行和 3 列,看起来像:
index inp aco count
0 2.3.6. dp-ptp-a2f 22000
1 2.3.12. ft-ptp-a2f 21300
2 2.5.9. dp-ptp-a2f 21010
3 0.8.0. dp-ptp-a4f 20000
4 2.3.6. ft-ptp-a2f 19000
5 2.3.6. ff-ptp-a2f 18500
... ...
... ...
... ...
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码透视数据框:
df1=df.pivot_table(values='count', index='inp', columns='aco',fill_value=0)
print(df1)
Run Code Online (Sandbox Code Playgroud)
但我得到了
IndexError: index 1491188345 is out of bounds for axis 0 with size 1491089723
Run Code Online (Sandbox Code Playgroud)