python 几个常用自定义函数在dataframe上的应用

 1 最小值与最大值
 2 
 3 def f(x):
 4 
 5   return pd.Series([x.min(),x.max(),index=['min','max'])
 6 
 7 frame.apply(f)
 8 
 9 
10 
11 浮点值的格式化
12 
13 format=lambda x:'%.2f' % x
14 
15 frame.applymap(format)#或者另一种用法frame['e'].map(format)

 

posted on 2018-01-21 10:35  hailuo  阅读(1855)  评论(0编辑  收藏  举报