代码:
df_paths = df.groupby('cookie')['channel'].aggregate(
lambda x: x.unique().tolist()).reset_index()
df_last_interaction = df.drop_duplicates('cookie', keep='last')[['cookie', 'conversion']]
df_paths = pd.merge(df_paths, df_last_interaction, how='left', on='cookie')
df_paths['path'] = np.where(
df_paths['conversion'] == 0,
['Start'] + df_paths['channel'] + ['Null'],
['Start'] + df_paths['channel'] + ['Conversion'])
df_paths = df_paths[['cookie', 'path']]
错误:
TypeError跟踪(最近一次通话最近) na_arithmetic_op中的/usr/local/lib/python3.6/dist-packages/pandas/core/ops/array_ops.py(left,right,op,str_rep) 148尝试: -> 149结果= expressions.evaluate(op,str_rep,左,右) 150,除了TypeError:
9幅 TypeError:必须为str,而不是列表
在处理上述异常期间,发生了另一个异常:
TypeError跟踪(最近一次通话最近) 在masked_arith_op(x,y,op)中的/usr/local/lib/python3.6/dist-packages/pandas/core/ops/array_ops.py 其他96个: 97如果不是is_scalar(y): ---> 98引发TypeError(type(y)) 99 100#遮罩仅对x有意义
TypeError: