dask.dataframe.from_dask_array

dask.dataframe.from_dask_array

dask.dataframe.from_dask_array(x, columns=None, index=None, meta=None)[source]

Create a Dask DataFrame from a Dask Array.

Converts a 2d array into a DataFrame and a 1d array into a Series.

Parameters
xda.Array
columnslist or string

list of column names if DataFrame, single string if Series

indexdask.dataframe.Index, optional

An optional dask Index to use for the output Series or DataFrame.

The default output index depends on whether x has any unknown chunks. If there are any unknown chunks, the output has None for all the divisions (one per chunk). If all the chunks are known, a default index with known divisions is created.

Specifying index can be useful if you’re conforming a Dask Array to an existing dask Series or DataFrame, and you would like the indices to match.

metaobject, optional

An optional meta parameter can be passed for dask to specify the concrete dataframe type to be returned. By default, pandas DataFrame is used.

See also

dask.bag.to_dataframe

from dask.bag

dask.dataframe._Frame.values

Reverse conversion

dask.dataframe._Frame.to_records

Reverse conversion

Examples

>>> import dask.array as da
>>> import dask.dataframe as dd
>>> x = da.ones((4, 2), chunks=(2, 2))
>>> df = dd.io.from_dask_array(x, columns=['a', 'b'])
>>> df.compute()
     a    b
0  1.0  1.0
1  1.0  1.0
2  1.0  1.0
3  1.0  1.0