to_numpy(self, dtype: 'npt.DTypeLike | None' = None, copy: 'bool' = False, na_value: 'Scalar' = <no_default>) -> 'np.ndarray'
By default converts to an object-dtype NumPy array. Specify the dtype
and :None:None:`na_value`
keywords to customize the conversion.
The numpy dtype to convert to.
Whether to ensure that the returned value is a not a view on the array. Note that copy=False
does not ensure that to_numpy()
is no-copy. Rather, copy=True
ensure that a copy is made, even if not strictly necessary. This is typically only possible when no missing values are present and dtype
is the equivalent numpy dtype.
Scalar missing value indicator to use in numpy array. Defaults to the native missing value indicator of this array (pd.NA).
Convert to a NumPy Array.
An object-dtype is the default result
This example is valid syntax, but we were not able to check execution>>> a = pd.array([True, False, pd.NA], dtype="boolean")
... a.to_numpy() array([True, False, <NA>], dtype=object)
When no missing values are present, an equivalent dtype can be used.
This example is valid syntax, but we were not able to check execution>>> pd.array([True, False], dtype="boolean").to_numpy(dtype="bool") array([ True, False])This example is valid syntax, but we were not able to check execution
>>> pd.array([1, 2], dtype="Int64").to_numpy("int64") array([1, 2])
However, requesting such dtype will raise a ValueError if missing values are present and the default missing value NA
is used.
>>> a = pd.array([True, False, pd.NA], dtype="boolean")This example is valid syntax, but we were not able to check execution
... a <BooleanArray> [True, False, <NA>] Length: 3, dtype: boolean
>>> a.to_numpy(dtype="bool") Traceback (most recent call last): ... ValueError: cannot convert to bool numpy array in presence of missing values
Specify a valid :None:None:`na_value`
instead
>>> a.to_numpy(dtype="bool", na_value=False) array([ True, False, False])See :
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them