Skip to content

Commit 8c569cf

Browse files
authored
type dataframe.transpose (#1136)
* type transpose * remove undocumented methods, use *args: Any instead of undocumented axes
1 parent bdd0946 commit 8c569cf

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

pandas-stubs/core/arrays/sparse/array.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin):
5353
def sum(self, axis: int = ..., *args, **kwargs): ...
5454
def cumsum(self, axis: int = ..., *args, **kwargs): ...
5555
def mean(self, axis: int = ..., *args, **kwargs): ...
56-
def transpose(self, *axes): ...
5756
@property
5857
def T(self): ...
5958
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...

pandas-stubs/core/base.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SelectionMixin(Generic[NDFrameT]):
4444

4545
class IndexOpsMixin(OpsMixin, Generic[S1]):
4646
__array_priority__: int = ...
47-
def transpose(self, *args, **kwargs) -> Self: ...
4847
@property
4948
def T(self) -> Self: ...
5049
@property

pandas-stubs/core/frame.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
656656
show_counts: bool | None = ...,
657657
) -> None: ...
658658
def memory_usage(self, index: _bool = ..., deep: _bool = ...) -> Series: ...
659-
def transpose(self, *args, copy: _bool = ...) -> Self: ...
659+
def transpose(self, *args: Any, copy: _bool = ...) -> Self: ...
660660
@property
661661
def T(self) -> Self: ...
662662
def __getattr__(self, name: str) -> Series: ...

pandas-stubs/core/series.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
15351535
bins: int | None = ...,
15361536
dropna: _bool = ...,
15371537
) -> Series[float]: ...
1538-
def transpose(self, *args, **kwargs) -> Series[S1]: ...
15391538
@property
15401539
def T(self) -> Self: ...
15411540
# The rest of these were left over from the old

tests/test_frame.py

+7
Original file line numberDiff line numberDiff line change
@@ -4005,6 +4005,13 @@ def test_hashable_args() -> None:
40054005
class GeoAccessor: ...
40064006

40074007

4008+
def test_transpose() -> None:
4009+
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]})
4010+
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame)
4011+
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame)
4012+
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)
4013+
4014+
40084015
def test_combine() -> None:
40094016
df1 = pd.DataFrame({"A": [0, 0], "B": [4, 4]})
40104017
df2 = pd.DataFrame({"A": [1, 1], "B": [3, 3]})

0 commit comments

Comments
 (0)