Skip to content

Commit e72e2dd

Browse files
authored
TYP: annotate to_numpy (#32809)
1 parent 095998c commit e72e2dd

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pandas/core/arrays/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ def __iter__(self):
356356
for i in range(len(self)):
357357
yield self[i]
358358

359-
def to_numpy(self, dtype=None, copy=False, na_value=lib.no_default):
359+
def to_numpy(
360+
self, dtype=None, copy: bool = False, na_value=lib.no_default
361+
) -> np.ndarray:
360362
"""
361363
Convert to a NumPy ndarray.
362364

pandas/core/arrays/numpy_.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ def skew(self, axis=None, dtype=None, out=None, keepdims=False, skipna=True):
435435

436436
# ------------------------------------------------------------------------
437437
# Additional Methods
438-
def to_numpy(self, dtype=None, copy=False, na_value=lib.no_default):
438+
439+
def to_numpy(
440+
self, dtype=None, copy: bool = False, na_value=lib.no_default
441+
) -> np.ndarray:
439442
result = np.asarray(self._ndarray, dtype=dtype)
440443

441444
if (copy or na_value is not lib.no_default) and result is self._ndarray:

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ def from_dict(cls, data, orient="columns", dtype=None, columns=None) -> "DataFra
12531253

12541254
return cls(data, index=index, columns=columns, dtype=dtype)
12551255

1256-
def to_numpy(self, dtype=None, copy=False) -> np.ndarray:
1256+
def to_numpy(self, dtype=None, copy: bool = False) -> np.ndarray:
12571257
"""
12581258
Convert the DataFrame to a NumPy array.
12591259

pandas/tests/extension/decimal/array.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _from_factorized(cls, values, original):
7979

8080
_HANDLED_TYPES = (decimal.Decimal, numbers.Number, np.ndarray)
8181

82-
def to_numpy(self, dtype=None, copy=False, na_value=no_default, decimals=None):
82+
def to_numpy(
83+
self, dtype=None, copy: bool = False, na_value=no_default, decimals=None
84+
) -> np.ndarray:
8385
result = np.asarray(self, dtype=dtype)
8486
if decimals is not None:
8587
result = np.asarray([round(x, decimals) for x in result])

0 commit comments

Comments
 (0)