Skip to content

Commit 29503fb

Browse files
committed
DOC: removed trailing whitespaces, added one more example, adjusted to PEP8
1 parent d642261 commit 29503fb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/core/frame.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2947,16 +2947,15 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
29472947
29482948
Examples
29492949
--------
2950-
>>> df = pd.DataFrame({'month': [1, 4, 7, 10],
2951-
... 'year': [2012, 2014, 2013, 2014],
2950+
>>> df = pd.DataFrame({'month': [1, 4, 7, 10],
2951+
... 'year': [2012, 2014, 2013, 2014],
29522952
... 'sale':[55, 40, 84, 31]})
29532953
month sale year
29542954
0 1 55 2012
29552955
1 4 40 2014
29562956
2 7 84 2013
29572957
3 10 31 2014
29582958
2959-
29602959
Set the index to become the 'month' column:
29612960
29622961
>>> df.set_index('month')
@@ -2967,7 +2966,6 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
29672966
7 84 2013
29682967
10 31 2014
29692968
2970-
29712969
Create a multi-index using columns 'year' and 'month':
29722970
29732971
>>> df.set_index(['year', 'month'])
@@ -2978,18 +2976,16 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
29782976
2013 7 84
29792977
2014 10 31
29802978
2981-
29822979
Create a multi-index using a set of values and a column:
29832980
29842981
>>> df.set_index([[1, 2, 3, 4], 'year'])
29852982
month sale
2986-
year
2983+
year
29872984
1 2012 1 55
29882985
2 2014 4 40
29892986
3 2013 7 84
29902987
4 2014 10 31
29912988
2992-
29932989
Returns
29942990
-------
29952991
dataframe : DataFrame

0 commit comments

Comments
 (0)