问题
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