I'm a python newbie and am having trouble reading a csv to pandas and working with it. Here is a bit of my csv file:
A B
1 56
2 76
3 23
4 45
5 54
6 65
7 22
And my python code:
import numpy as np
import pandas as pd
from math import exp
from math import sqrt
g = pd.DataFrame.from_csv('test.csv')
a = g.iloc[2:4,1]
print(a)
I get the following error:
IndexError: index 1 is out of bounds for axis 0 with size 1
I've also tried:
a = g.iloc[2:4,'B']
and many other permutations for defining columns and rows.
Also when I print g, I get the following:
B
A
2015-05-01 56
2015-05-02 76
2015-05-03 23
2015-05-04 45
2015-05-05 54
2015-05-06 65
2015-05-07 22
I can't understand why A and B are not aligned.
I'm just using this an example, but in general I'd like to read in large csv files and then perform operations on certain aspects of the matrix.
Any help would be appreciated.