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

Function from_array

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

5002
5003
5004def from_array(arr, chunksize=50_000, columns=None, meta=None):
5005 """Read any sliceable array into a Dask Dataframe
5006
5007 Uses getitem syntax to pull slices out of the array. The array need not be
5008 a NumPy array but must support slicing syntax
5009
5010 x[50000:100000]
5011
5012 and have 2 dimensions:
5013
5014 x.ndim == 2
5015
5016 or have a record dtype:
5017
5018 x.dtype == [('name', 'O'), ('balance', 'i8')]
5019
5020 Parameters
5021 ----------
5022 x : array_like
5023 chunksize : int, optional
5024 The number of rows per partition to use.
5025 columns : list or string, optional
5026 list of column names if DataFrame, single string if Series
5027 meta : object, optional
5028 An optional `meta` parameter can be passed for dask
5029 to specify the concrete dataframe type to use for partitions of
5030 the Dask dataframe. By default, pandas DataFrame is used.
5031
5032 Returns
5033 -------
5034 dask.DataFrame or dask.Series
5035 A dask DataFrame/Series
5036 """
5037 import dask.array as da
5038
5039 if isinstance(arr, da.Array):
5040 return from_dask_array(arr, columns=columns, meta=meta)
5041
5042 from dask.dataframe.dask_expr.io.io import FromArray
5043
5044 result = FromArray(
5045 arr,
5046 chunksize=chunksize,
5047 original_columns=columns,
5048 meta=meta,
5049 )
5050 if pyarrow_strings_enabled() and arr.dtype.kind in "OU":
5051 result = expr.ArrowStringConversion(result)
5052 return new_collection(result)
5053
5054
5055def 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