map()函数语法:
map(function,iterable…) -> function – 函数 iterable – 一个或多个序列
案例
s1 = [1,2,3,4,5]
s2 = [6,7,8,9,10]
s3 = map(lambda x,y:x*y,s1,s2)
list(s3)
>>>[6, 14, 24, 36, 50]
zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。
函数语法:
zip([iterable, …]) ->iterabl – 一个或多个迭代器;
->返回元组列表
案例
a = [1,2,3,4]
b = [5,6,7,8]
zipped = zip(a,b)
print(list(zipped))
zipped = zip(a,b)
print(list(zip(*zipped)))
>>>
[(1, 5), (2, 6), (3, 7), (4, 8)]
[(1, 2, 3, 4), (5, 6, 7, 8)]
在pandas.map apply applymap中的 map(),apply(),applymap() 函数
df = pd.DataFrame(np.random.randn(4,5),columns=list('abcde'),index=list('1234'))
df
>>>
a b c d e
1 0.495790 -0.689097 -