Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
現在、上部にデータフレームがあります。groupby 関数を使用して別のデータフレームを取得し、データをグループ化し、単語を次のような形式に連結する方法はありますか?
ありがとう
[
さらにインクを節約したい場合は、関数を使用して各グループに適用できるため、.apply()使用する必要はありません。.agg()
.apply()
.agg()
df.groupby('id')['words'].agg(','.join)
また
# this way you can add multiple columns and different aggregates as needed. df.groupby('id').agg({'words': ','.join})