I would like to read a dataframe (which contains tweets) row by row in order to analyze the text.
import csv
import pandas as pd
df = pd.read_csv('tweets2.csv')
df.head()
for row in df.iterrows():
print (row)
This code I wrote does not do the job, since the "row" also includes the index. Instead, I want the simple text, that I will process further.
You could use df.values
:
for row in df.values:
print(row)
Example:
df = pd.DataFrame({'Col1': [1, 2, 3, 4, 5], 'Col2' : ['a', 'b', 'c', 'd', 'e']})
print(df)
Col1 Col2
0 1 a
1 2 b
2 3 c
3 4 d
4 5 e
for row in df.values:
print(row)
[1 'a']
[2 'b']
[3 'c']
[4 'd']
[5 'e']
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments