I think you need strip for remove first and last
and then split for list of words:
for i in range(0, 1):
print ('synonyms section ' + str(i + 1))
print (pd.DataFrame({'text': synonyms[i].text.strip().split()}))
text
0 guardian
1 custodian
2 warden
3 keeper
4 sentry
.. ...
211 soldier
212 park
213 ranger
214 more
215 ?
[216 rows x 1 columns]
If need all values to DataFrame use extend
method for add lists to L
list and then call DataFrame constructor outside loop:
L = []
for i, syno in enumerate(synonyms):
print ('synonyms section ' + str(i + 1))
L.extend(syno.text.strip().split())
df = pd.DataFrame({'text':L})
print(df)
text
0 guardian
1 custodian
2 warden
3 keeper
4 sentry
...
7667 Languages
7668 g
7669 gu
7670 gua
7671 guar
[7672 rows x 1 columns]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…