I have a dask dataframe and a dask array with the same number of rows in the same logical order. The dataframe rows are indexed by strings. I am trying to add one of the array columns to the dataframe. I have tried several ways all of which failed in their particular way.
df['col'] = da.col
# TypeError: Column assignment doesn't support type Array
df['col'] = da.to_frame(columns='col')
# TypeError: '<' not supported between instances of 'str' and 'int'
df['col'] = da.to_frame(columns=['col']).set_index(df.col).col
# TypeError: '<' not supported between instances of 'str' and 'int'
df = df.reset_index()
df['col'] = da.to_frame(columns='col')
# ValueError: Not all divisions are known, can't align partitions. Please use `set_index` to set the index.
and a few other variants.
What is the right way to add a dask array column to a dask dataframe when the structures are logically compatible?