If I have a Pandas dataframe, and a column that is a datetime type, I can get the year as follows:
df['year'] = df['date'].dt.year
With a dask dataframe, that does not work. If I compute first, like this:
df['year'] = df['date'].compute().dt.year
I get ValueError: Not all divisions are known, can't align partitions. Please use
set_indexor
set_partitionto set the index.
But if I do:
df['date'].head().dt.year
it works fine!
So how do I get the year (or week) of a datetime series in a dask dataframe?