map:对指定序列做映射

python3中的:

map(function, iterable, ...)

map(lambda x, y: x + y, [1, 3, 5, 7, 9], [2, 4, 6, 8, 10])

lambda 形参:返回值                 实参

再如:

a = {'1': ['88.12', '28100', '23'], '8': ['88.05', '2400', '3']} 把里面元素的转化成适当的数字

a = dict(map(lambda x:( int(x[0]), [float(x[1][0]), int(x[1][1]), int(x[1][2])]) ,a.items()))

pandas中:

df_int = df["trading_day"].map(lambda x: self.dash_convert_int(x)) #dataframe是无法用map函数的,对它的某列可以,因为map是对指定序列.
 
模仿这一方法的操作:

result["datetime"] = [convert_date_to_date_int(pd.to_datetime(str(dt))) for dt in data.index.values]

python的map函数的更多相关文章

  1. python的map()函数

    map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. 例如,对于list [1, 2 ...

  2. Python中map()函数浅析

    MapReduce的设计灵感来自于函数式编程,这里不打算提MapReduce,就拿python中的map()函数来学习一下. 文档中的介绍在这里: map(function, iterable, .. ...

  3. Python中map函数

    1.简介 python 提供内置函数map(), 接收两个参数,一个是函数,一个是序列,map将传入的函数依次作用到序列的每个元素,并把结果作为新的list返回.例如: (1)对于list [1, 2 ...

  4. python的map函数和reduce函数(转)

    map函数 map()函数 map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. 例 ...

  5. python中map()函数

    map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. map()是 Python 内 ...

  6. python的map函数的使用方法详解以及使用案例(处理每个元素的自增、自减、平方等)

    1.用我们之前学过的求一下平方(只有一个列表) #求平方 num=[1,5,6,2,7,8] a=[] for n in num: a.append(n**2) print (a) C:\python ...

  7. python 3 map函数用法

    公式 f是定义的函数,l是你的list,所有功能都在f函数里完成, map(f,l) 有些网址爬虫出来的链接是一部分,省略了前端通用的,这时我们需要补充进去, 这时就用到了map函数,批量补充网址, ...

  8. python中map()函数的用法讲解

    map函数的原型是map(function, iterable, -),它的返回结果是一个列表. 参数function传的是一个函数名,可以是python内置的,也可以是自定义的. 参数iterabl ...

  9. python:map 函数

    map(func, *iterables) --> map object map()是 Python 内置的高阶函数,它接收一个函数 func 和一个 list(*iterables),并通过把 ...

  10. python之Map函数

    # map()函数使用举例 # 功能:map()接受一个函数f和一个或多个list,将f依次作用在list的每个元素,得到一个新的列表 # 语法:map(方法名,列表,[列表2]) # 注意:map( ...

随机推荐

  1. NUC972 linux 烧录

    节介绍如何刻录uboot.kernel和文件系统到NAND Flash, 并且设定NUC970系列芯片从NAND Flash中开机.本节操作需要windows环境下进行.(初次连接电脑需要安装驱动) ...

  2. JS控制只能输入数字并且最多允许小数点两位

    直接上代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  3. HDU 4725 The Shortest Path in Nya Graph(构图)

    The Shortest Path in Nya Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  4. 关于linux-Centos 7下mysql 5.7.9的rpm包的安装方式

    环境介绍>>>>>>>>>>>>>>>>>> 操作系统:Centos 7.1 mysql数据 ...

  5. Configure GenieACS

    GenieACS General Config config.json acts as the main configuration file and is stored in /path_to_ge ...

  6. F - Communication System

    We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...

  7. python 多返回值

    多返回值: def count(): fs = [] for i in range(1, 4): def f(j): def g(): return j*j return g fs.append(f( ...

  8. Oracle客户端的安装与远程连接配置

    在继续Oracle客户端的安装之前,需要分析一下Oracle客户端与数据库服务器之间的连接机制. 一.Oracle客户端与服务器端的通讯机制 1.Oracle Net协议 如下图所示,Oracle通过 ...

  9. VMware与Centos系统安装 和重置root密码

    VMware与Centos系统安装   今日任务 1.Linux发行版的选择 2.vmware创建一个虚拟机(centos) 3.安装配置centos7 4.xshell配置连接虚拟机(centos) ...

  10. TensorRT 不支持Tensorflow的操作有如下

    tf.unpack, tf.slice, tf.tile, tf.expand_dims, tf.fill, tf.cast, tf.floor_div, tf.range 比较坑,所以你必须限制你的 ...