S.S
S.S

Reputation: 41

Adding one minute to dataframe index column Python

I have a dataframe dataFull where the index column is Timestamp. I would like to add a minute to the timestamp of each row in the same dataframe. Something like below. Could you please help me?

dataFull['Timestamp'] = dataFull.index[0] + dat.timedelta(minutes=1)

Dataframe is in below format

I would like to have Timestamp field increase by 1 minute for each data row

enter image description here

Upvotes: 1

Views: 473

Answers (1)

tdy
tdy

Reputation: 41477

If Timestamp is the actual dataframe index, you cannot access it as df['Timestamp'] anymore.

First make sure the index is datetime, then add pd.Timedelta(minutes=1):

dataFull.index = pd.to_datetime(dataFull.index)
dataFull.index = dataFull.index + pd.Timedelta(minutes=1)

Upvotes: 1

Related Questions