I tried to create a new column called brought_profit_to_company, by filtering other two columns product_id and refunded, however it has resulted in some errors:
df['brought_profit_to_company'] = 10
if (df['product_id'] == 7.99 & df['refunded'] == True):
df['brought_profit_to_company'] = 0
elif (df['product_id'] == '49.99'):
df['brought_profit_to_company'] == 49.99
else:
df['brought_profit_to_company'] = df['product_id'] * (df['days_used_app'] * 1)
but it has resulted in this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/ops/array_ops.py in na_logical_op(x, y, op)
301 # (xint or xbool) and (yint or bool)
--> 302 result = op(x, y)
303 except TypeError:
8 frames
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'bool'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/core/ops/array_ops.py in na_logical_op(x, y, op)
326 f"Cannot perform '{op.__name__}' with a dtyped [{x.dtype}] array "
327 f"and scalar of type [{typ}]"
--> 328 ) from err
329
330 return result.reshape(x.shape)
TypeError: Cannot perform 'rand_' with a dtyped [bool] array and scalar of type [bool]
Here is also dtypes of columns
user_id int64
product_id float64
trial bool
refunded bool
purchase_date_x datetime64[ns]
country_code object
media_source object
days_used_app int64
dtype: object