C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Reset IndexThe Reset index of the DataFrame is used to reset the index by using the 'reset_index' command. If the DataFrame has a MultiIndex, this method can remove one or more levels. Syntax: DataFrame.reset_index(self, level=None, drop=False, inplace=False, col_level=0, col_fill='') Parameters: level : Refers to int, str, tuple, or list, default value None It is used to remove the given levels from the index and also removes all levels by default. drop : Refers to Boolean value, default value False It resets the index to the default integer index. inplace : Refers to Boolean value, default value False It is used to modify the DataFrame in place and does not require to create a new object. col_level : Refers to int or str, default value 0 It determines level the labels are inserted if the column have multiple labels col_fill : Refers to an object, default value '' It determines how the other levels are named if the columns have multiple level. Example1: info = pd.DataFrame([('William', 'C'), ('Smith', 'Java'), ('Parker', 'Python'), ('Phill', np.nan)], index=[1, 2, 3, 4], columns=('name', 'Language')) info info.reset_index() Output: index name Language 0 1 William C 1 2 Smith Java 2 3 Parker Python 3 4 Phill NaN
Next TopicSet Index
|