2

I pulled out one column from the data frame and added it to a variable named timestamp.

0    2017-01-10 04:45:00
1    2017-01-10 04:45:00
2    2017-01-10 04:45:00
3    2017-01-10 04:46:00
4    2017-01-10 04:46:00
5    2017-01-10 04:46:00
6    2017-01-10 04:47:00
7    2017-01-10 04:47:00
8    2017-01-10 17:47:00
9    2017-01-10 17:52:00
Name: timestamp, dtype: object

The type of data is:

type(timestamp)

Out[1]: pandas.core.series.Series

type(timestamp.values)

Out[1]: numpy.ndarray

What I want to do is add 9 hours.

0    2017-01-10 13:45:00
1    2017-01-10 13:45:00
2    2017-01-10 13:45:00
3    2017-01-10 13:46:00
4    2017-01-10 13:46:00
5    2017-01-10 13:46:00
6    2017-01-10 13:47:00
7    2017-01-10 13:47:00
8    2017-01-11 02:47:00
9    2017-01-11 02:52:00
Name: timestamp, dtype: object

I would appreciate it if you could tell me what I should do.

Cian
  • 80
  • 1
  • 10

1 Answers1

4

Use pd.Timedelta:

 s1 + pd.Timedelta(hours=9)

Output:

0   2017-01-10 13:45:00
1   2017-01-10 13:45:00
2   2017-01-10 13:45:00
3   2017-01-10 13:46:00
4   2017-01-10 13:46:00
5   2017-01-10 13:46:00
6   2017-01-10 13:47:00
7   2017-01-10 13:47:00
8   2017-01-11 02:47:00
9   2017-01-11 02:52:00
Name: 1, dtype: datetime64[ns]
Scott Boston
  • 147,308
  • 15
  • 139
  • 187