python的map函数

map:对指定序列做映射

python3中的:

map(function, iterable, ...)

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

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]

猜你喜欢

转载自www.cnblogs.com/Stephen-Qin/p/10296219.html