Skip to content
Advertisement

Build a dask dataframe from a list of dask delayed objects

I have a list of dask delayed objects Portfolio_perfs:

JavaScript

Each delayed object is a numpy array of length 2

JavaScript

I want to build the following dataframe without using dask.compute:

JavaScript

How can I build this dask dataframe without going through dask.compute? Thank you

Advertisement

Answer

Since each delayed object is a numpy array, you are interested in da.from_delayed():

JavaScript

Alternatively, it’s possible to convert numpy arrays to pandas dataframes and then use:

JavaScript

Note that it’s not possible to do it with pd.DataFrame because pandas will not know what to do with the delayed objects, so you will need to use dask.dataframe for this task.

Advertisement