timedelta

Python 3.9: Construct DST valid timestamp using standard library

☆樱花仙子☆ 提交于 2021-02-19 04:35:07
问题 I would like to contruct DST-valid timestamps only using the standard library in Python 3.9 and was hoping this was possible with this version. In my timezone "Europe/Berlin", the DST crossings for 2020 are: 2020-03-29 at 02:00 the clock switches to 03:00 (there is no hour 2!) 2020-10-25 at 03:00 the clock switches back to 02:00 (the hour 2 exists two times!) My script yields the following output: MARCH 2020-03-29 01:59:00+01:00 CET plus 1 h: 2020-03-29 02:59:00+01:00 CET (should be 03:59:00

TypeError using timedelta, cannot sum times

杀马特。学长 韩版系。学妹 提交于 2021-02-11 04:56:14
问题 I have data that looks like this: user in out location flag Time 0 ron 12/21/2021 10:11 12/21/2016 17:50 home 0 4:19:03 1 ron 12/21/2016 13:26 12/21/2016 13:52 office 2 0:25:28 2 april 12/21/2016 8:12 12/21/2016 17:27 office 0 8:15:03 3 april 12/21/2016 18:54 12/21/2016 22:56 office 0 4:02:36 4 andy 12/21/2016 8:57 12/21/2016 12:15 home 0 2:59:40 I want to sum or take the max value of time per user based on the flag. So I converted the column to timedelta. sample.loc[:,'Time'] = pd.to

TypeError using timedelta, cannot sum times

▼魔方 西西 提交于 2021-02-11 04:55:25
问题 I have data that looks like this: user in out location flag Time 0 ron 12/21/2021 10:11 12/21/2016 17:50 home 0 4:19:03 1 ron 12/21/2016 13:26 12/21/2016 13:52 office 2 0:25:28 2 april 12/21/2016 8:12 12/21/2016 17:27 office 0 8:15:03 3 april 12/21/2016 18:54 12/21/2016 22:56 office 0 4:02:36 4 andy 12/21/2016 8:57 12/21/2016 12:15 home 0 2:59:40 I want to sum or take the max value of time per user based on the flag. So I converted the column to timedelta. sample.loc[:,'Time'] = pd.to

TypeError using timedelta, cannot sum times

痞子三分冷 提交于 2021-02-11 04:55:25
问题 I have data that looks like this: user in out location flag Time 0 ron 12/21/2021 10:11 12/21/2016 17:50 home 0 4:19:03 1 ron 12/21/2016 13:26 12/21/2016 13:52 office 2 0:25:28 2 april 12/21/2016 8:12 12/21/2016 17:27 office 0 8:15:03 3 april 12/21/2016 18:54 12/21/2016 22:56 office 0 4:02:36 4 andy 12/21/2016 8:57 12/21/2016 12:15 home 0 2:59:40 I want to sum or take the max value of time per user based on the flag. So I converted the column to timedelta. sample.loc[:,'Time'] = pd.to

pandas: calculate time difference between df columns [duplicate]

北城以北 提交于 2021-02-11 02:31:50
问题 This question already has answers here : Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes (3 answers) Closed 6 months ago . I have two df columns with string values: df['starttime'] df['endtime'] 0 2015-10-06 18:35:33 0 2015-10-06 18:35:58 1 2015-10-08 17:51:21.999000 1 2015-10-08 17:52:10 2 2015-10-08 20:51:55.999000 2 2015-10-08 20:52:21 3 2015-10-05 15:16:49.999000 3 2015-10-05 15:17:00 4 2015-10-05 15:16:53.999000 4 2015-10-05 15:17:22 5 2015-10-05 15:17

pandas: calculate time difference between df columns [duplicate]

别来无恙 提交于 2021-02-11 02:23:56
问题 This question already has answers here : Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes (3 answers) Closed 6 months ago . I have two df columns with string values: df['starttime'] df['endtime'] 0 2015-10-06 18:35:33 0 2015-10-06 18:35:58 1 2015-10-08 17:51:21.999000 1 2015-10-08 17:52:10 2 2015-10-08 20:51:55.999000 2 2015-10-08 20:52:21 3 2015-10-05 15:16:49.999000 3 2015-10-05 15:17:00 4 2015-10-05 15:16:53.999000 4 2015-10-05 15:17:22 5 2015-10-05 15:17

pandas: calculate time difference between df columns [duplicate]

孤街浪徒 提交于 2021-02-11 02:23:22
问题 This question already has answers here : Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes (3 answers) Closed 6 months ago . I have two df columns with string values: df['starttime'] df['endtime'] 0 2015-10-06 18:35:33 0 2015-10-06 18:35:58 1 2015-10-08 17:51:21.999000 1 2015-10-08 17:52:10 2 2015-10-08 20:51:55.999000 2 2015-10-08 20:52:21 3 2015-10-05 15:16:49.999000 3 2015-10-05 15:17:00 4 2015-10-05 15:16:53.999000 4 2015-10-05 15:17:22 5 2015-10-05 15:17

Pandas - Expanding average session time

邮差的信 提交于 2021-02-04 16:01:12
问题 The following DF represents events received from users. Id of the user and the timestamp of the event: id timestamp 0 1 2020-09-01 18:14:35 1 1 2020-09-01 18:14:39 2 1 2020-09-01 18:14:40 3 1 2020-09-01 02:09:22 4 1 2020-09-01 02:09:35 5 1 2020-09-01 02:09:53 6 1 2020-09-01 02:09:57 7 2 2020-09-01 18:14:35 8 2 2020-09-01 18:14:39 9 2 2020-09-01 18:14:40 10 2 2020-09-01 02:09:22 11 2 2020-09-01 02:09:35 12 2 2020-09-01 02:09:53 13 2 2020-09-01 02:09:57 I would like to get the average expanding

How can I subtract timedeltas listed in same column?

别等时光非礼了梦想. 提交于 2021-01-29 08:14:05
问题 I have this data: count MySum MyCount User Name time_diff Logon Time 192309 -134 days +18:08:00 1 1 34 34 -129 days +11:05:00 1 1 34 34 -124 days +15:00:00 1 1 34 34 -124 days +11:04:00 1 1 34 34 -124 days +01:26:00 1 1 34 34 ... ... ... ... 193143 -116 days +21:53:00 1 1 1 1 164883 -119 days +15:32:00 1 1 1 1 200580 -1 days +19:39:00 1 1 1 1 183396 -102 days +01:50:00 1 1 1 1 184806 -6 days +06:15:00 1 1 1 1 Derived from this: new_col_dipl = (counting_dipl_new.to_frame('count').join(

Get the time spent since midnight in dataframe

最后都变了- 提交于 2021-01-28 09:59:55
问题 I have a dataframe which has a column of type Timestamp. I want to find the time elapsed (in seconds) since midnight as a new column. How to do it in a simple way ? Eg : Input : samples['time'] 2018-10-01 00:00:01.000000000 2018-10-01 00:00:12.000000000 type(samples['time'].iloc[0]) <class 'pandas._libs.tslib.Timestamp'> Output : samples['time_elapsed'] 1 12 回答1: Note that the date part in each row may be other (not from one and the same day), so you can not take any "base date" ( midnight )