![](/img/trans.png)
[英]how to convert multiple rows into single row for same id using pandas
[英]Convert multiple rows of text into a Single row using Pandas
嘗試通過agg()
, to_frame()
和reset_index()
:
out=(df.agg(' '.join)
.to_frame('text')
.reset_index(drop=True))
out 的輸出:
text
0 Hi how are you I am fine I love you I hate you
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.