0
來自以下數據框;熊貓:結合行中的文本
data1 = pd.DataFrame({'Section':[1,1,1,2,2,2,2],'Sub':['What','is','this?','I','am','not','sure.']})
我該如何得到與此類似的結果;
['What is this?','I am not sure.']
到目前爲止,我只能想出像這樣的groupby
;
for d in data1.groupby(['Section'])['Sub']:
print d[1]
它給你這樣的東西;
0 What
1 is
2 this?
Name: Sub, dtype: object
3 I
4 am
5 not
6 sure.
Name: Sub, dtype: object
爽!非常感謝! – richie
@richie np,很樂意幫忙;) – zhangxaochen