Back to Vaex

Dask

docs/source/guides/dask.ipynb

4.19.0968 B
Original Source

Dask

If you want to try out this notebook with a live Python kernel, use mybinder:

<a class="reference external image-reference" href="https://mybinder.org/v2/gh/vaexio/vaex/latest?filepath=docs%2Fsource%2Fexample_dask.ipynb"></a>

Dask.array

A vaex dataframe can be lazily converted to a dask.array using DataFrame.to_dask_array.

python
import vaex
df = vaex.example()
df
python
# convert a set of columns in the dataframe to a 2d dask array
A = df[['x', 'y', 'z']].to_dask_array()
A
python
import dask.array as da
# lazily compute with dask
r = da.sqrt(A[:,0]**2 + A[:,1]**2 + A[:,2]**2)
r
python
# materialize the data
r_computed = r.compute()
r_computed
python
# put it back in the dataframe
df['r'] = r_computed
df