pythonpandassuper

Getting into the definition of the Pandas.Series super().reindex


I am interested in seeing the source code of the pandas.Series.reindex, so I jumped to the source code using the link in the documentation page, yet I found a return to other function super().reindex, which I could not yet find out where this function was introduced. How can I get into the definition of this function pandas.Series.reindex?


Solution

  • super().reindex calls the reindex method from Series' parent class. Series class definition is

    class Series(base.IndexOpsMixin, NDFrame):
    

    So there are 2 parent classes. In the import at the top of the file you can see that base is imported from pandas.core and NDFrame from pandas.core.generic

    In the base.py there is no reindex function but in the class NDFrame there is. You can find the reindex() function there:

    https://github.com/pandas-dev/pandas/blob/v2.2.3/pandas/core/generic.py#L5347 (permalink)