我想将dataframe列中的所有字符串转换为单个空字符串,然后将其转换为单词列表:
string = ""
for i,j in df.iterrows():
string += j["read"]
Output:
'Redismyfavoritecolor'
Required Output:
"Red is my favorite color"
我试图加入字符串,但是我不知道如何添加空格。
if ( price > 0 && discount > 0 ) {
return price - price * discount / 100
} else {
console.log('Invalid data')
}
答案 0 :(得分:7)
将join
与空格一起使用:
out = ' '.join(df["read"])
print (out)
Red is my favorite color