8

Suppose I have a set of dask arrays such as:

c1 = da.from_array(np.arange(100000, 190000), chunks=1000)
c2 = da.from_array(np.arange(200000, 290000), chunks=1000)
c3 = da.from_array(np.arange(300000, 390000), chunks=1000)

is it possible to create a dask dataframe from them? In pandas i could say:

data = {}
data['c1'] = c1
data['c2'] = c2
data['c3'] = c3

df = pd.DataFrame(data)

is there a similar way to do this with dask?

1
  • 2
    I suspect that you could do this with a combination of dd.from_dask_array and dd.concat(..., axis=1). Commented Mar 28, 2017 at 2:28

1 Answer 1

13

The following should work:

import pandas as pd, numpy as np 
import dask.array as da, dask.dataframe as dd

c1 = da.from_array(np.arange(100000, 190000), chunks=1000)
c2 = da.from_array(np.arange(200000, 290000), chunks=1000)
c3 = da.from_array(np.arange(300000, 390000), chunks=1000)

# generate dask dataframe
ddf = dd.concat([dd.from_dask_array(c) for c in [c1,c2,c3]], axis = 1) 
# name columns
ddf.columns = ['c1', 'c2', 'c3']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.