python的map函数

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]

新战场:https://blog.csdn.net/Stephen___Qin
原文地址:https://www.cnblogs.com/Stephen-Qin/p/10296219.html