Home > Back-end >  How to change the index values to start from 0
How to change the index values to start from 0

Time:07-09

rolling_window = 120
df = df.rolling(rolling_window, min_periods=1).agg(['mean','std'])
df.columns = df.columns.map('_'.join)
# df = df.reset_index()
df = df.iloc[(rolling_window-1):,]
df = df.rename_axis('timestamps').reset_index()
df = df.set_index('timestamps')

the dataframe get index position start from 119 but I want to start from 0. how to reset?

CodePudding user response:

df.reset_index(drop=True)

The drop attribute specifies whether the previously used index column should be removed.

  • Related