我有一个类似于以下内容的分组字符串df:
chat_type message
Account My Account is missing money
Account I need to update my account
Benefits My benefits suck
Benefits Where is my benefit check
所需的输出
chat_type message
Account My Account is missing money I need to update my account
Benefits My benefits suck Where is my benefits check
我尝试的
解决方案dfn = df.groupby('chat_type')['message'].join()
返回此消息
AttributeError: 'SeriesGroupBy' object has no attribute 'join'
答案 0 :(得分:1)
尝试:
df=df.groupby('chat_type')['message'].apply(' '.join).reset_index()