I'm trying to understand the axis
parameter in python pandas
. I understand that it's analogous to the numpy axis, but the following example still confuses me:
a = pd.DataFrame([[0, 1, 4], [1, 2, 3]])
print a
0 1 2
0 0 1 4
1 1 2 3
According to this post, axis=0
runs along the rows (fixed column), while axis=1
runs along the columns (fixed row). Running print a.drop(1, axis=1)
yields
0 2
0 0 4
1 1 3
which results in a dropped column, while print a.drop(1, axis=0)
drops a row. Why? That seems backwards to me.