@@ -3924,22 +3924,36 @@ def shift(self, periods=1, freq=None, axis=0):
39243924 def  set_index (self , keys , drop = True , append = False , inplace = False ,
39253925 verify_integrity = False ):
39263926 """ 
3927+  Set the DataFrame index using existing columns. 
3928+ 
39273929 Set the DataFrame index (row labels) using one or more existing 
3928-  columns. By default yields a new object . 
3930+  columns. The index can replace the existing index or expand on it . 
39293931
39303932 Parameters 
39313933 ---------- 
3932-  keys : column label or list of column labels / arrays 
3933-  drop : boolean, default True 
3934-  Delete columns to be used as the new index 
3935-  append : boolean, default False 
3936-  Whether to append columns to existing index 
3937-  inplace : boolean, default False 
3938-  Modify the DataFrame in place (do not create a new object) 
3939-  verify_integrity : boolean, default False 
3934+  keys : label or list of label 
3935+  Name or names of the columns that will be used as the index. 
3936+  drop : bool, default True 
3937+  Delete columns to be used as the new index. 
3938+  append : bool, default False 
3939+  Whether to append columns to existing index. 
3940+  inplace : bool, default False 
3941+  Modify the DataFrame in place (do not create a new object). 
3942+  verify_integrity : bool, default False 
39403943 Check the new index for duplicates. Otherwise defer the check until 
39413944 necessary. Setting to False will improve the performance of this 
3942-  method 
3945+  method. 
3946+ 
3947+  Returns 
3948+  ------- 
3949+  DataFrame 
3950+  Changed row labels. 
3951+ 
3952+  See Also 
3953+  -------- 
3954+  DataFrame.reset_index : Opposite of set_index. 
3955+  DataFrame.reindex : Change to new indices or expand indices. 
3956+  DataFrame.reindex_like : Change to same indices as other DataFrame. 
39433957
39443958 Returns 
39453959 ------- 
@@ -3949,22 +3963,23 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
39493963 -------- 
39503964 >>> df = pd.DataFrame({'month': [1, 4, 7, 10], 
39513965 ... 'year': [2012, 2014, 2013, 2014], 
3952-  ... 'sale':[55, 40, 84, 31]}) 
3953-  month sale year 
3954-  0 1 55 2012 
3955-  1 4 40 2014 
3956-  2 7 84 2013 
3957-  3 10 31 2014 
3966+  ... 'sale': [55, 40, 84, 31]}) 
3967+  >>> df 
3968+  month year sale 
3969+  0 1 2012 55 
3970+  1 4 2014 40 
3971+  2 7 2013 84 
3972+  3 10 2014 31 
39583973
39593974 Set the index to become the 'month' column: 
39603975
39613976 >>> df.set_index('month') 
3962-  sale year  
3977+  year sale  
39633978 month 
3964-  1 55  2012  
3965-  4 40  2014  
3966-  7 84  2013  
3967-  10 31  2014  
3979+  1 2012  55  
3980+  4 2014  40  
3981+  7 2013  84  
3982+  10 2014  31  
39683983
39693984 Create a multi-index using columns 'year' and 'month': 
39703985
@@ -4072,22 +4087,22 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
40724087 def  reset_index (self , level = None , drop = False , inplace = False , col_level = 0 ,
40734088 col_fill = '' ):
40744089 """ 
4075-  For DataFrame with multi-level  index, return new DataFrame with  
4076-  labeling information in the columns under the index names, defaulting 
4077-  to 'level_0', 'level_1', etc. if any are None. For a standard index,  
4078-  the index name will be used (if set), otherwise a default 'index' or  
4079-  'level_0' (if 'index' is already taken) will be used . 
4090+  Reset the  index, or a level of it.  
4091+ 
4092+  Reset the index of the DataFrame, and use the default one instead.  
4093+  If  the DataFrame has a MultiIndex, this method can remove one or more  
4094+  levels . 
40804095
40814096 Parameters 
40824097 ---------- 
40834098 level : int, str, tuple, or list, default None 
40844099 Only remove the given levels from the index. Removes all levels by 
4085-  default 
4086-  drop : boolean , default False 
4100+  default.  
4101+  drop : bool , default False 
40874102 Do not try to insert index into dataframe columns. This resets 
40884103 the index to the default integer index. 
4089-  inplace : boolean , default False 
4090-  Modify the DataFrame in place (do not create a new object) 
4104+  inplace : bool , default False 
4105+  Modify the DataFrame in place (do not create a new object).  
40914106 col_level : int or str, default 0 
40924107 If the columns have multiple levels, determines which level the 
40934108 labels are inserted into. By default it is inserted into the first 
@@ -4098,13 +4113,20 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
40984113
40994114 Returns 
41004115 ------- 
4101-  resetted : DataFrame 
4116+  DataFrame 
4117+  DataFrame with the new index. 
4118+ 
4119+  See Also 
4120+  -------- 
4121+  DataFrame.set_index : Opposite of reset_index. 
4122+  DataFrame.reindex : Change to new indices or expand indices. 
4123+  DataFrame.reindex_like : Change to same indices as other DataFrame. 
41024124
41034125 Examples 
41044126 -------- 
4105-  >>> df = pd.DataFrame([('bird',   389.0), 
4106-  ... ('bird',   24.0), 
4107-  ... ('mammal',   80.5), 
4127+  >>> df = pd.DataFrame([('bird', 389.0), 
4128+  ... ('bird', 24.0), 
4129+  ... ('mammal', 80.5), 
41084130 ... ('mammal', np.nan)], 
41094131 ... index=['falcon', 'parrot', 'lion', 'monkey'], 
41104132 ... columns=('class', 'max_speed')) 
0 commit comments