Search code examples
pythonpandasseries

How to reindex pandas Series by removing nulls between different indices?


I have a pandas Series that goes by 5 in indexes like the image;

A Pandas dataframe with indexes incrementing by 5

I want to transform this Pandas Series to;

  1. 20.883339
  2. 20.883386
  3. 20.883434

...

3652 21.053699

Can I transform my Pandas series like that without creating a new series?


Solution

  • Resetting the index with drop=True will replace it with the default 0-indexed integer index:

    y_pred = y_pred.reset_index(drop=True)