给定以下DF
0
0 Maintain the distance.
1 Ensure it is checked.
2 Inbetween distance must be 0.5.
3 Take extra notes of the distance.Pandas是否有可能加入所有行,给出新行并将结果作为变量返回?
最后产出:
可变n
Maintain the distance.
Ensure it is checked.
Inbetween distance must be 0.5.
Take extra notes of the distance.我已经研究过str.cat(),但似乎分隔符不允许使用\n。
发布于 2022-09-04 03:56:26
尽可能多地使用\n换行符。
>>> df = pd.DataFrame(dict(word='a man a plan a canal'.split()))
>>> df
word
0 a
1 man
2 a
3 plan
4 a
5 canal
>>>
>>> text = df.word.str.cat(sep='\n\n')
>>> print(text)
a
man
a
plan
a
canalhttps://stackoverflow.com/questions/73596669
复制相似问题