Taking the following example:
>>> df1 = pd.DataFrame({\"x\":[1, 2, 3, 4, 5],
\"y\":[3, 4, 5, 6, 7]},
ind
This is my trick with axis: just add the operation in your mind to make it sound clear:
If you “sum” through axis=0, you are summing all rows, and the output will be a single row with the same number of columns. If you “sum” through axis=1, you are summing all columns, and the output will be a single column with the same number of rows.