Skip to content

DOC: Add docstring for DataFrame.T property #50766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,32 @@ def transpose(self, *args, copy: bool = False) -> DataFrame:

@property
def T(self) -> DataFrame:
"""
The transpose of the DataFrame.

Returns
-------
DataFrame
The transposed DataFrame.

Examples
--------
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
>>> df
col1 col2
0 1 3
1 2 4

>>> df.T
0 1
col1 1 2
col2 3 4


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be only one blank line here.

And it seems more appropriate that the order is Returns, See also, Examples.

Copy link
Contributor Author

@smij720 smij720 Jan 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - agreed. I have made those changes.

(for anyone else reading this - the reordering edit in response to this feedback means that the doc sections in the code now match the order in which the docs are rendered, which makes more sense)

See Also
--------
DataFrame.transpose : Transpose index and columns.
"""
return self.transpose()

# ----------------------------------------------------------------------
Expand Down