MCPcopy
hub / github.com/pandas-dev/pandas / get_array

Function get_array

pandas/tests/copy_view/util.py:9–30  ·  view source on GitHub ↗

Helper method to get array for a DataFrame column or a Series. Equivalent of df[col].values, but without going through normal getitem, which triggers tracking references / CoW (and we might be testing that this is done by some other operation).

(obj, col=None)

Source from the content-addressed store, hash-verified

7
8
9def get_array(obj, col=None):
10 """
11 Helper method to get array for a DataFrame column or a Series.
12
13 Equivalent of df[col].values, but without going through normal getitem,
14 which triggers tracking references / CoW (and we might be testing that
15 this is done by some other operation).
16 """
17 if isinstance(obj, Index):
18 arr = obj._values
19 elif isinstance(obj, Series) and (col is None or obj.name == col):
20 arr = obj._values
21 else:
22 assert col is not None
23 icol = obj.columns.get_loc(col)
24 assert isinstance(icol, int)
25 arr = obj._get_column_array(icol)
26 if isinstance(arr, BaseMaskedArray):
27 return arr._data
28 elif isinstance(arr, Categorical):
29 return arr
30 return getattr(arr, "_ndarray", arr)

Calls 2

_get_column_arrayMethod · 0.80
get_locMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…