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

Function from_array

dask/dataframe/dask_expr/_collection.py:4929–4977  ·  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

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