简体   繁体   English

熊猫-枢轴输入错误

[英]Pandas — Type error from Pivot

I have the data below. 我有下面的数据。

在此处输入图片说明

I am trying to create a pivot table, with 'Profile ID' at the side, and 'Booking Type' as the column headers. 我正在尝试创建一个数据透视表,其中的侧面有“配置文件ID”,列标题为“ Booking Type”。

dfpivot=y.pivot_table(index='Profile Id', columns='Booking Type', aggfunc='count', fill_value=0)

But I encounter the error below. 但是我遇到下面的错误。

TypeError: '>' not supported between instances of 'str' and 'int' TypeError:“ str”和“ int”的实例之间不支持“>”

Does anyone knows why? 有谁知道为什么?

通过将“预订类型”(Booking Type)列转换为字符串格式解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM