>>> data=pd.DataFrame(np.arange(16).reshape((4,4)),index=['a','b','c','d'],columns=['one','two','three','four'])
>>> data
one two three four
a 0 1 2 3
b 4 5 6 7
c 8 9 10 11
d 12 13 14 15
>>> data.mean(axis=1)
a 1.5
b 5.5
c 9.5
d 13.5
dtype: float64
>>> data.drop('two',axis=1)
one three four
a 0 2 3
b 4 6 7
c 8 10 11
d 12 14 15
Q .Pandas中用drop函数时,axis=1删掉的是一列,但运算的时候axis=1代表按行运算,这是为什么呢?
A:axis=1代表跨行,axis=0代表跨列,即axis=x按照第x个下标的变化计算。