0
我有以下格式的數據(CSV文件):組合多個值,在Python
id, review
1, the service was great!
1, staff was friendly.
2, nice location
2, but the place was not clean
2, the motel was okay
3, i wouldn't stay there next time
3, do not stay there
我想數據更改爲以下格式:
1, the service was great! staff was friendly.
2, nice location but the place was not clean the motel was okay
3, i wouldn't stay there next time do not stay there
任何幫助將不勝感激。
你有什麼迄今所做的:讀取該文件假設它是一個真正的CSV文件,與
,
分隔符的代碼?由於最後一行不是以'1'開始,而是在之前被添加到行中,所以匹配標準是什麼? – albert看看'itertools.groupby'。 – Kevin
@albert我糾正了輸出。 – kevin