I have a CSV file, I want to iterate each row of only one specific column.
Let's say, the column name is "phrase", there are 1000 rows in this column as follows:
| ID | phrase |
|---|---|
| 1 | apple |
| 2 | banana |
| ... | ... |
How can I iterate each cell in this column?
I have tried to use:
df = pd.read_csv('myfile.csv', usecols=[1])
for row in df:
print(row)
I only get value of the first row of this column, not iterate each row, as follows:
Current output:
phrase
Desired output:
phrase # with or without this one are all OK
apple
banana
Does anyone know how can I get the desired result? Thanks!
rowto list?list('abc')is['a', 'b', 'c']. Also, do you -really- needpandas? can you just use thecsvmodule directly? Also2, you can just dodf.phrase.tolist()