PADAS中MAP、Applymap和应用方法的区别你能告诉我什么时候使用这些矢量化方法和基本例子吗?我看到了map是Series方法,而其余的则是DataFrame方法。我对apply和applymap但是方法。为什么我们有两个将函数应用到DataFrame的方法?再次,简单的例子,说明使用将是伟大的!
3 回答

翻翻过去那场雪
TA贡献2065条经验 获得超14个赞
DataFrame.apply
一次在整行或列上操作。 DataFrame.applymap
,Series.apply
,和 Series.map
同时对一个元素进行操作。
Series.apply
Series.map

烙印99
TA贡献1829条经验 获得超13个赞
应用程序可以使DataFrame从一个系列中提取出来。
In [40]: p=pd.Series([1,2,3])In [41]: pOut[31]:0 11 22 3dtype: int64In [42]: p.apply(lambda x: pd.Series([x, x]))Out[42]: 0 10 1 11 2 22 3 3In [43]: p.map(lambda x: pd.Series([x, x]))Out[43]: 0 0 11 1dtype: int641 0 21 2dtype: int642 0 31 3dtype: int64 dtype: object
apply
series.apply(download_file_for_every_element)
Map
1 2 3 4 52 1 4 5 3
1 2 3 4 51 2 5 3 4
map
0.15.1
.
In [39]: p=pd.Series([1,0,3,4,2])In [40]: p.map(p)Out[40]: 0 01 12 43 24 3dtype: int64
添加回答
举报
0/150
提交
取消