Python TypeError:参数类型为';int';不可编辑(使用lambda)
我有这个:Python TypeError:参数类型为';int';不可编辑(使用lambda),python,pandas,numpy,Python,Pandas,Numpy,我有这个: TypeError: argument of type 'int' is not iterable 如何修复它?有一个问题,InvoiceNo列中的多个或所有值都是整数 如果混合列值(C在样本数据中未显示的其他值中)通过以下方式强制转换为strings,则可能的解决方案: 另一个解决方案包括: 如果所有值都是整数,则不存在C,因此始终获取0您可以创建吗?每个购物篮['InvoiceNo']包含哪些nb\u产品?提供一个例子,请更新问题 TypeError: argument of
TypeError: argument of type 'int' is not iterable
如何修复它?有一个问题,
InvoiceNo列中的多个或所有值都是整数
如果混合列值(C
在样本数据中未显示的其他值中)通过以下方式强制转换为string
s,则可能的解决方案:
另一个解决方案包括:
如果所有值都是整数,则不存在C
,因此始终获取0
您可以创建吗?每个购物篮['InvoiceNo']
包含哪些nb\u产品?提供一个例子,请更新问题
TypeError: argument of type 'int' is not iterable
nb_products_per_basket['order_canceled'] =
nb_products_per_basket['InvoiceNo'].astype(str).apply(lambda x:int('C' in x))
nb_products_per_basket['order_canceled'] =
nb_products_per_basket['InvoiceNo'].str.contains('C', na=False).astype(int)