Suppose we want to change the order of the index of series, then we have to use the Series.reindex() Method of pandas module for performing this task.
Series, which is a 1-D labeled array capable of holding any data.
Syntax: pandas.Series(data, index, dtype, copy)
- data takes ndarrys, list, constants.
- index values.
- dtypes for data types.
- Copy data, default is False.
For knowing more about the pandas Series click here.
Series.reindex() Method is used for changing the data on the basis of indexes.
Syntax: Series.reindex(labels=None, index=None, columns=None, axis=None, method=None, copy=True, level=None, fill_value=nan, limit=None, tolerance=None)
For knowing more about the pandas Series.reindex() method click here.
Let’s create a series:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course