MCPcopy Create free account
hub / github.com/dask/dask / from_array

Function from_array

dask/dataframe/dask_expr/_collection.py:4926–4974  ·  view source on GitHub ↗

Read any sliceable array into a Dask Dataframe Uses getitem syntax to pull slices out of the array. The array need not be a NumPy array but must support slicing syntax x[50000:100000] and have 2 dimensions: x.ndim == 2 or have a record dtype: x.dtype ==

(arr, chunksize=50_000, columns=None, meta=None)

Source from the content-addressed store, hash-verified

4924
4925
4926def from_array(arr, chunksize=50_000, columns=None, meta=None):
4927 """Read any sliceable array into a Dask Dataframe
4928
4929 Uses getitem syntax to pull slices out of the array. The array need not be
4930 a NumPy array but must support slicing syntax
4931
4932 x[50000:100000]
4933
4934 and have 2 dimensions:
4935
4936 x.ndim == 2
4937
4938 or have a record dtype:
4939
4940 x.dtype == [('name', 'O'), ('balance', 'i8')]
4941
4942 Parameters
4943 ----------
4944 x : array_like
4945 chunksize : int, optional
4946 The number of rows per partition to use.
4947 columns : list or string, optional
4948 list of column names if DataFrame, single string if Series
4949 meta : object, optional
4950 An optional `meta` parameter can be passed for dask
4951 to specify the concrete dataframe type to use for partitions of
4952 the Dask dataframe. By default, pandas DataFrame is used.
4953
4954 Returns
4955 -------
4956 dask.DataFrame or dask.Series
4957 A dask DataFrame/Series
4958 """
4959 import dask.array as da
4960
4961 if isinstance(arr, da.Array):
4962 return from_dask_array(arr, columns=columns, meta=meta)
4963
4964 from dask.dataframe.dask_expr.io.io import FromArray
4965
4966 result = FromArray(
4967 arr,
4968 chunksize=chunksize,
4969 original_columns=columns,
4970 meta=meta,
4971 )
4972 if pyarrow_strings_enabled() and arr.dtype.kind in "OU":
4973 result = expr.ArrowStringConversion(result)
4974 return new_collection(result)
4975
4976
4977def from_graph(layer, _meta, divisions, keys, name_prefix):

Callers 5

test_from_arrayFunction · 0.90
to_numericFunction · 0.70

Calls 4

from_dask_arrayFunction · 0.90
FromArrayClass · 0.90
pyarrow_strings_enabledFunction · 0.90
new_collectionFunction · 0.90

Tested by 4

test_from_arrayFunction · 0.72