以下按预期工作:
def genres_names (row):
data = str(row['genres'])
...
return ...
data_df['genres_names'] = data_df.apply(genres_names, axis=1)
概括地说,我想传递一个参数:
def names (row, column):
data = str(row[column])
...
return ...
data_df['genres_names'] = data_df.apply(names('genres'), axis=1)
这不起作用:
TypeError: names() missing 1 required positional argument: 'column'
传递column='genres'
会加注
TypeError: genres_names() missing 1 required positional argument: 'row'
不确定如何访问该行...