https://www.cnblogs.com/rrttp/p/8028421.html
axis=0代表往跨行(down),
而axis=1代表跨列(across),
如果我们调用df.mean(axis=1),我们将得到按行计算的均值
#python中的axis究竟是如何定义的呢?他们究竟代表是DataFrame的行还是列?考虑以下代码:
>>>df = pd.DataFrame([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], \
columns=["col1", "col2", "col3", "col4"])
>>>df
col1 col2 col3 col4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
#如果我们调用df.mean(axis=1),我们将得到按行计算的均值
>>> df.mean(axis=1)
0 1
1 2
2 3
#然而,如果我们调用 df.drop((name, axis=1),我们实际上删掉了一列,而不是一行:
>>> df.drop("col4", axis=1)
col1 col2 col3
0 1 1 1
1 2 2 2
2 3 3 3