0

Am I misunderstanding the axis parameter? In one situation using .drop() the rows are affected by axis=0 and in another situation using .sum() the columns are affected by axis=0.

df = pd.DataFrame({"a":[1,4,7], "b":[2,5,8], "c":[3,6,9]})
df

    a   b   c
0   1   2   3
1   4   5   6
2   7   8   9

# affects rows
df.drop([1], axis=0)

    a   b   c
0   1   2   3
2   7   8   9


# affects columns
df.sum(axis=0)

a    12
b    15
c    18
dtype: int64
michotross
  • 364
  • 3
  • 12
  • This is something I have noticed as well. It is inconsistent as far as I can tell and I just have to check the documentation. – James Apr 15 '19 at 00:39
  • @James I have link the question hope it can help – BENY Apr 15 '19 at 00:49

0 Answers0