When using this simple example
import pandas as pd
df = pd.DataFrame({'c1': [10, 11, 12], 'c2': [100, 110, 120]})
for index, row in df.iterrows():
print(row['c1'], row['c2'])
There is no problem in writing row['c1']
.
However when I have a csv file like
t, p1, p2, p3, p4, vis
1, 0, 0, 0, 1, 10
2, 0.1, 0, 0, 0.9, 12
3, 0.2, 0, 0, 0.8, 15
4, 0.2, 0.3, 0, 0.5 ,18
and I do
df3 = pd.read_csv('test2.csv', index_col=0)
print(df3)
I got
p1 p2 p3 p4 vis
t
1 0.0 0.0 0 1.0 10
2 0.1 0.0 0 0.9 12
3 0.2 0.0 0 0.8 15
4 0.2 0.3 0 0.5 18
so far so good, right? However when I try to do this
print(df3['vis'])
I got an error. I cannot do either df3[0]
Why is this happening and how can I get the column?