Skip to content

Commit 80e3d7e

Browse files
igorcadelimacemsbr
andcommitted
DOC: Improve the docstring of DataFrame.transpose()
Co-authored-by: Carlos Eduardo Moreira dos Santos <[email protected]> Signed-off-by: Igor C. A. de Lima <[email protected]> Signed-off-by: Carlos Eduardo Moreira dos Santos <[email protected]>
1 parent 85817a7 commit 80e3d7e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

pandas/core/frame.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,48 @@ def memory_usage(self, index=True, deep=False):
22892289
return result
22902290

22912291
def transpose(self, *args, **kwargs):
2292-
"""Transpose index and columns"""
2292+
"""
2293+
Transpose index and columns.
2294+
2295+
Reflect the dataframe over its main diagonal by writing rows as columns
2296+
and vice-versa.
2297+
2298+
Parameters
2299+
----------
2300+
*args
2301+
These arguments will be passed to
2302+
:func:`pandas.compat.numpy.function.validate_transpose`.
2303+
**kwargs
2304+
Keyword arguments used to create the transposed DataFrame.
2305+
2306+
Returns
2307+
-------
2308+
:class:`~pandas.DataFrame`
2309+
The transposed DataFrame.
2310+
2311+
See Also
2312+
--------
2313+
numpy.transpose : Permute the dimensions of a given array.
2314+
2315+
Examples
2316+
--------
2317+
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
2318+
>>> df = pd.DataFrame(data=d)
2319+
>>> df
2320+
col1 col2
2321+
0 1 3
2322+
1 2 4
2323+
2324+
>>> df.T
2325+
0 1
2326+
col1 1 2
2327+
col2 3 4
2328+
2329+
>>> df.transpose()
2330+
0 1
2331+
col1 1 2
2332+
col2 3 4
2333+
"""
22932334
nv.validate_transpose(args, dict())
22942335
return super(DataFrame, self).transpose(1, 0, **kwargs)
22952336

0 commit comments

Comments
 (0)