Skip to content

Commit d77669e

Browse files
committed
DOC: add further type hints to public API methods in pandas/core/generic.py pandas-dev#26792
1 parent ee97477 commit d77669e

File tree

1 file changed

+25
-49
lines changed

1 file changed

+25
-49
lines changed

pandas/core/generic.py

+25-49
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,7 @@ def _obj_with_exclusions(self):
627627
""" internal compat with SelectionMixin """
628628
return self
629629

630-
def set_axis(self,
631-
labels: Sequence[Any],
632-
axis=0,
633-
inplace=False) -> "NDFrame":
630+
def set_axis(self, labels: Sequence[Any], axis=0, inplace=False) -> "NDFrame":
634631
"""
635632
Assign desired index to given axis.
636633
@@ -777,10 +774,7 @@ def transpose(self, *args, **kwargs) -> "NDFrame":
777774
nv.validate_transpose(tuple(), kwargs)
778775
return self._constructor(new_values, **new_axes).__finalize__(self)
779776

780-
def swapaxes(self,
781-
axis1: int,
782-
axis2: int,
783-
copy=True) -> "NDFrame":
777+
def swapaxes(self, axis1: int, axis2: int, copy=True) -> "NDFrame":
784778
"""
785779
Interchange axes and swap values axes appropriately.
786780
@@ -805,9 +799,9 @@ def swapaxes(self,
805799

806800
return self._constructor(new_values, *new_axes).__finalize__(self)
807801

808-
def droplevel(self,
809-
level: Union[int, str, Sequence[Union[int, str]]],
810-
axis=0) -> "NDFrame":
802+
def droplevel(
803+
self, level: Union[int, str, Sequence[Union[int, str]]], axis=0
804+
) -> "NDFrame":
811805
"""
812806
Return DataFrame with requested index / column level(s) removed.
813807
@@ -866,8 +860,7 @@ def droplevel(self,
866860
result = self.set_axis(new_labels, axis=axis, inplace=False)
867861
return result
868862

869-
def pop(self,
870-
item: str) -> "pd.Series":
863+
def pop(self, item: str) -> "pd.Series":
871864
"""
872865
Return item and drop from frame. Raise KeyError if not found.
873866
@@ -1385,10 +1378,9 @@ class name
13851378
if not inplace:
13861379
return result
13871380

1388-
def _set_axis_name(self,
1389-
name: Union[str, List[str]],
1390-
axis=0,
1391-
inplace=False) -> "NDFrame":
1381+
def _set_axis_name(
1382+
self, name: Union[str, List[str]], axis=0, inplace=False
1383+
) -> "NDFrame":
13921384
"""
13931385
Set the name(s) of the axis.
13941386
@@ -1457,8 +1449,7 @@ def _indexed_same(self, other):
14571449
self._get_axis(a).equals(other._get_axis(a)) for a in self._AXIS_ORDERS
14581450
)
14591451

1460-
def equals(self,
1461-
other: "NDFrame") -> bool:
1452+
def equals(self, other: "NDFrame") -> bool:
14621453
"""
14631454
Test whether two objects contain the same elements.
14641455
@@ -1636,9 +1627,7 @@ def __round__(self, decimals=0):
16361627
# operations should utilize/extend these methods when possible so that we
16371628
# have consistent precedence and validation logic throughout the library.
16381629

1639-
def _is_level_reference(self,
1640-
key: str,
1641-
axis=0) -> bool:
1630+
def _is_level_reference(self, key: str, axis=0) -> bool:
16421631
"""
16431632
Test whether a key is a level reference for a given axis.
16441633
@@ -1668,9 +1657,7 @@ def _is_level_reference(self,
16681657
and not self._is_label_reference(key, axis=axis)
16691658
)
16701659

1671-
def _is_label_reference(self,
1672-
key: str,
1673-
axis=0) -> bool:
1660+
def _is_label_reference(self, key: str, axis=0) -> bool:
16741661
"""
16751662
Test whether a key is a label reference for a given axis.
16761663
@@ -1699,9 +1686,7 @@ def _is_label_reference(self,
16991686
and any(key in self.axes[ax] for ax in other_axes)
17001687
)
17011688

1702-
def _is_label_or_level_reference(self,
1703-
key: str,
1704-
axis=0) -> bool:
1689+
def _is_label_or_level_reference(self, key: str, axis=0) -> bool:
17051690
"""
17061691
Test whether a key is a label or level reference for a given axis.
17071692
@@ -1725,9 +1710,7 @@ def _is_label_or_level_reference(self,
17251710
key, axis=axis
17261711
)
17271712

1728-
def _check_label_or_level_ambiguity(self,
1729-
key: str,
1730-
axis=0) -> None:
1713+
def _check_label_or_level_ambiguity(self, key: str, axis=0) -> None:
17311714
"""
17321715
Check whether `key` is ambiguous.
17331716
@@ -1776,9 +1759,7 @@ def _check_label_or_level_ambiguity(self,
17761759
)
17771760
raise ValueError(msg)
17781761

1779-
def _get_label_or_level_values(self,
1780-
key: str,
1781-
axis=0) -> np.ndarray:
1762+
def _get_label_or_level_values(self, key: str, axis=0) -> np.ndarray:
17821763
"""
17831764
Return a 1-D array of values associated with `key`, a label or level
17841765
from the given `axis`.
@@ -1850,9 +1831,7 @@ def _get_label_or_level_values(self,
18501831

18511832
return values
18521833

1853-
def _drop_labels_or_levels(self,
1854-
keys: Union[str, List[str]],
1855-
axis=0) -> "NDFrame":
1834+
def _drop_labels_or_levels(self, keys: Union[str, List[str]], axis=0) -> "NDFrame":
18561835
"""
18571836
Drop labels and/or levels for the given `axis`.
18581837
@@ -2493,10 +2472,9 @@ def to_json(
24932472
indent=indent,
24942473
)
24952474

2496-
def to_hdf(self,
2497-
path_or_buf: Union[str, FilePathOrBuffer],
2498-
key: str,
2499-
**kwargs) -> None:
2475+
def to_hdf(
2476+
self, path_or_buf: Union[str, FilePathOrBuffer], key: str, **kwargs
2477+
) -> None:
25002478
"""
25012479
Write the contained data to an HDF5 file using HDFStore.
25022480
@@ -2601,10 +2579,9 @@ def to_hdf(self,
26012579

26022580
pytables.to_hdf(path_or_buf, key, self, **kwargs)
26032581

2604-
def to_msgpack(self,
2605-
path_or_buf: Optional[FilePathOrBuffer] =None,
2606-
encoding="utf-8",
2607-
**kwargs) -> None:
2582+
def to_msgpack(
2583+
self, path_or_buf: Optional[FilePathOrBuffer] = None, encoding="utf-8", **kwargs
2584+
) -> None:
26082585
"""
26092586
Serialize object to input file path using msgpack format.
26102587
@@ -2800,10 +2777,9 @@ def to_sql(
28002777
method=method,
28012778
)
28022779

2803-
def to_pickle(self,
2804-
path: str,
2805-
compression="infer",
2806-
protocol=pickle.HIGHEST_PROTOCOL) -> None:
2780+
def to_pickle(
2781+
self, path: str, compression="infer", protocol=pickle.HIGHEST_PROTOCOL
2782+
) -> None:
28072783
"""
28082784
Pickle (serialize) object to file.
28092785

0 commit comments

Comments
 (0)