Converting a Dask column into new Dask column of type datetime

这一生的挚爱 提交于 2021-02-08 04:29:10

问题


I have an unparsed column in a dask dataframe (df) that I am using pandas to convert to datetime and put into a new column in the dask dataframe. However it breaks as column assignment doesn't support type DatetimeIndex.

df['New Column'] = pd.to_datetime(np.array(df.index.values), format='%Y/%m/%d %H:%M')

回答1:


this should work

import dask.dataframe as dd
# note df is a dask dataframe 
df['New Column'] = dd.to_datetime(df.index, format='%Y/%m/%d %H:%M')


来源:https://stackoverflow.com/questions/51420042/converting-a-dask-column-into-new-dask-column-of-type-datetime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!