Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pandas-stubs/core/arrays/sparse/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin):
def sum(self, axis: int = ..., *args, **kwargs): ...
def cumsum(self, axis: int = ..., *args, **kwargs): ...
def mean(self, axis: int = ..., *args, **kwargs): ...
def transpose(self, *axes): ...
@property
def T(self): ...
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class SelectionMixin(Generic[NDFrameT]):

class IndexOpsMixin(OpsMixin, Generic[S1]):
__array_priority__: int = ...
def transpose(self, *args, **kwargs) -> Self: ...
@property
def T(self) -> Self: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
show_counts: bool | None = ...,
) -> None: ...
def memory_usage(self, index: _bool = ..., deep: _bool = ...) -> Series: ...
def transpose(self, *args, copy: _bool = ...) -> Self: ...
def transpose(self, *args: Any, copy: _bool = ...) -> Self: ...
@property
def T(self) -> Self: ...
def __getattr__(self, name: str) -> Series: ...
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
bins: int | None = ...,
dropna: _bool = ...,
) -> Series[float]: ...
def transpose(self, *args, **kwargs) -> Series[S1]: ...
@property
def T(self) -> Self: ...
# The rest of these were left over from the old
Expand Down
7 changes: 7 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4002,6 +4002,13 @@ def test_hashable_args() -> None:
class GeoAccessor: ...


def test_transpose() -> None:
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]})
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame)
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame)
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)


def test_combine() -> None:
df1 = pd.DataFrame({"A": [0, 0], "B": [4, 4]})
df2 = pd.DataFrame({"A": [1, 1], "B": [3, 3]})
Expand Down
7 changes: 7 additions & 0 deletions tests/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,3 +1272,10 @@ def test_datetime_index_max_min_reductions() -> None:
check(assert_type(dtidx.argmin(), np.int64), np.int64)
check(assert_type(dtidx.max(), pd.Timestamp), pd.Timestamp)
check(assert_type(dtidx.min(), pd.Timestamp), pd.Timestamp)


def test_transpose() -> None:
idx: pd.Index[int] = pd.Index([1, 1, 2])
check(assert_type(idx.transpose(), "pd.Index[int]"), pd.Index, np.int64)
check(assert_type(idx.transpose(None), "pd.Index[int]"), pd.Index, np.int64)
check(assert_type(idx.transpose(axes=None), "pd.Index[int]"), pd.Index, np.int64)
7 changes: 7 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3672,3 +3672,10 @@ def test_info() -> None:
check(assert_type(s.info(show_counts=True), None), type(None))
check(assert_type(s.info(show_counts=False), None), type(None))
check(assert_type(s.info(show_counts=None), None), type(None))


def test_transpose() -> None:
s: pd.Series[int] = pd.Series([1, 1, 2])
check(assert_type(s.transpose(), "pd.Series[int]"), pd.Series, np.int64)
check(assert_type(s.transpose(None), "pd.Series[int]"), pd.Series, np.int64)
check(assert_type(s.transpose(axes=None), "pd.Series[int]"), pd.Series, np.int64)
Loading