博客
关于我
Python中的map函数
阅读量:341 次
发布时间:2019-03-03

本文共 433 字,大约阅读时间需要 1 分钟。

>>>def square(x) :            # 计算平方数...     return x ** 2... >>> map(square, [1,2,3,4,5])   # 计算列表各个元素的平方[1, 4, 9, 16, 25]>>> map(lambda x: x ** 2, [1, 2, 3, 4, 5])  # 使用 lambda 匿名函数[1, 4, 9, 16, 25] # 提供了两个列表,对相同位置的列表数据进行相加>>> map(lambda x, y: x + y, [1, 3, 5, 7, 9], [2, 4, 6, 8, 10])[3, 7, 11, 15, 19]

map(function, iterable, …)

用于操作数据处理中很常见

data['date'] = list(map(lambda x,y:str(x)+"."+str(y),data['regYear'],data['regMonth']))

转载地址:http://jysl.baihongyu.com/

你可能感兴趣的文章
new对象时,JVM内部究竟藏了什么小秘密?
查看>>
new操作符的实现原理
查看>>
Next.js React Server Components 教程
查看>>
NextGen Mirth Connect XStream反序列化远程代码执行漏洞(CVE-2023-43208)
查看>>
next项目部署到服务器pm2进程守护
查看>>
nexus 介绍
查看>>
nexus上传jar
查看>>
Nexus指南中的更新强调集成和透明度的重要性
查看>>
Nexus指南已经发布
查看>>
Nexus(1):Nexus的安装与配置
查看>>
NFC技术:概述
查看>>
NFinal学习笔记 02—NFinalBuild
查看>>
NFS
查看>>
nfs mount 故障 mount.nfs: access denied by server while mounting 10.0.100.208:/backup_usb
查看>>
NFS Server及Client配置与挂载详解
查看>>
NFS 服务配置篇
查看>>
NFS共享文件系统搭建
查看>>
nfs复习
查看>>
NFS安装配置
查看>>
NFS服务器配置-服务启动与停止
查看>>