我使用函数的apply更新数据框,但现在我需要使用这个函数修改多列。
以下是我的示例代码:
def update_row(row):
listy = [1,2,3]
return listy
dp_data_df[['A', 'P','Y']] = dp_data_df.apply(update_row, axis=1)
它抛出了以下错误:
ValueError: shape mismatch: value array of shape (10,) could not be broadcast to indexing result of shape (3,10)
提前感谢您。