所以我有一个数据框 df 像这样:
current_user.post_set.all
,我想基于 neighborhood 列的值合并所有列和行:
description title tags neighborhood
humm asd yes p9
blow com nope p9
rest hiya mouse p8
wow good com p8
我尝试了以下代码:
keywords neighborhood
humm asd yes blow com nope p9
rest hiya mouse wow good com p8
但是结果是这样的:
df2= pd.DataFrame()
df2['keywords'] = df[['description', 'title', 'tags']].agg(' '.join, axis=1)
有人可以帮助我吗?