机器学习:pandas库

1.Dataframe单列的数据变换

map()函数,apply()函数

df[c[1]].map(lambda x : x+1)

df[c[1]].map(func)

df[c[1]].apply(func)

2.Dataframe多列间的数据变换

apply()函数

df[ c[5] ] =  df.apply(lambda x:x[ c[1] ]/x[ c[4] ],axis=1)

x带表当前行


3.分组运算,聚合函数

可以结合groupby与transform来方便地实现类似SQL中的聚合运算的操作


猜你喜欢

转载自blog.csdn.net/qq_34706955/article/details/80842736