首页 > 代码库 > python pandas 数据处理

python pandas 数据处理

from pandas import Series,DataFrame
import pandas as pd
import numpy as np

python中pandas.DataFrame对行与列求和及添加新行与列示例

df = DataFrame(np.random.randn(4, 5), columns=[‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘])
df[‘Col_sum‘] = df.apply(lambda x: x.sum(), axis=1)
df.loc[‘Row_sum‘] = df.apply(lambda x: x.sum())

python pandas 数据处理