Skip to content

Commit 69ed654

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 dd7f567 commit 69ed654

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
@@ -1978,7 +1978,48 @@ def memory_usage(self, index=True, deep=False):
19781978
return result
19791979

19801980
def transpose(self, *args, **kwargs):
1981-
"""Transpose index and columns"""
1981+
"""
1982+
Transpose index and columns.
1983+
1984+
Reflect the dataframe over its main diagonal by writing rows as columns
1985+
and vice-versa.
1986+
1987+
Parameters
1988+
----------
1989+
*args
1990+
These arguments will be passed to
1991+
:func:`pandas.compat.numpy.function.validate_transpose`.
1992+
**kwargs
1993+
Keyword arguments used to create the transposed DataFrame.
1994+
1995+
Returns
1996+
-------
1997+
:class:`~pandas.DataFrame`
1998+
The transposed DataFrame.
1999+
2000+
See Also
2001+
--------
2002+
numpy.transpose : Permute the dimensions of a given array.
2003+
2004+
Examples
2005+
--------
2006+
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
2007+
>>> df = pd.DataFrame(data=d)
2008+
>>> df
2009+
col1 col2
2010+
0 1 3
2011+
1 2 4
2012+
2013+
>>> df.T
2014+
0 1
2015+
col1 1 2
2016+
col2 3 4
2017+
2018+
>>> df.transpose()
2019+
0 1
2020+
col1 1 2
2021+
col2 3 4
2022+
"""
19822023
nv.validate_transpose(args, dict())
19832024
return super(DataFrame, self).transpose(1, 0, **kwargs)
19842025

0 commit comments

Comments
 (0)