import numpy as np
import pandas as pd
from pandas import Series,DataFrame
3.4 函数应用和映射
df1 = DataFrame(
np.random.choice(range(20),size=(4,3),replace=False),
index=list('ABCD'),
columns=list('abc'))
df1
a b c
A 14 19 17
B 1 13 18
C 12 9 0
D 5 2 7
- 使用 numpy 的函数操作
np.sum(df1,axis=0)
a 32
b 43
c 42
dtype: int64
- 使用numpy的函数操作,axis=0 跨行