Home>

If i have the following data frame (Series),
I want to advance all timestamps by 9 hours. (I want to do this in 9 hours)

Maybe it's basic, but I'm not sure how to do it,
I would appreciate it if anyone could tell me.

  • Answer # 1

    I think

    pandas.Timedeltashould be used.

    >>>import pandas as pd
    >>>ser = pd.Series ([pd.Timestamp ("2019 12 12 1: 23: 1"), pd.Timestamp ("2019 12 1 23: 21: 4")])
    >>>ser + pd.Timedelta (hours = 9)
    0 2019-12-12 10:23:01
    1 2019-12-02 08:21:04
    dtype: datetime64 [ns]

    Time deltas — pandas 0.25.3 documentation
    pandas.Timedelta — pandas 0.23.4 documentation

Related articles