nb_products_per_basket['order_canceled'] =
nb_products_per_basket['InvoiceNo'].apply(lambda x:int('C' in x))
I have this :
TypeError: argument of type 'int' is not iterable
how can I fix it ?
There is problem one, multiple or all values are integers in column InvoiceNo.
Possible solution if mixed column values (C are in another values not shown in sample data) is cast it to strings by astype:
nb_products_per_basket['order_canceled'] =
nb_products_per_basket['InvoiceNo'].astype(str).apply(lambda x:int('C' in x))
Another solution with str.contains:
nb_products_per_basket['order_canceled'] =
nb_products_per_basket['InvoiceNo'].str.contains('C', na=False).astype(int)
If all values are integers there are no C, so always get 0.
nb_products_per_basket['InvoiceNo']contains? Provide an example, please