datetime

round a date in R to an arbitrary minute/hour level of precision

和自甴很熟 提交于 2021-02-04 17:08:19
问题 I'm looking to group dates in R by an arbitrary level of precision. It's pretty straightforward to do this to the nearest hour or minute, using e.g. lubridate : library(lubridate) nearest_hour = floor_date(now(), 'hour') You can then group a list of such dates with e.g. a simple summarise ddply from plyr . What I'd like to do is round dates with arbitrary precision, e.g. to the nearest 15 minutes or every 3 hours: nearest_three_hours = floor_date(now(), '3 hours') There's a discussion of such

round a date in R to an arbitrary minute/hour level of precision

て烟熏妆下的殇ゞ 提交于 2021-02-04 17:07:33
问题 I'm looking to group dates in R by an arbitrary level of precision. It's pretty straightforward to do this to the nearest hour or minute, using e.g. lubridate : library(lubridate) nearest_hour = floor_date(now(), 'hour') You can then group a list of such dates with e.g. a simple summarise ddply from plyr . What I'd like to do is round dates with arbitrary precision, e.g. to the nearest 15 minutes or every 3 hours: nearest_three_hours = floor_date(now(), '3 hours') There's a discussion of such

round a date in R to an arbitrary minute/hour level of precision

北慕城南 提交于 2021-02-04 17:07:28
问题 I'm looking to group dates in R by an arbitrary level of precision. It's pretty straightforward to do this to the nearest hour or minute, using e.g. lubridate : library(lubridate) nearest_hour = floor_date(now(), 'hour') You can then group a list of such dates with e.g. a simple summarise ddply from plyr . What I'd like to do is round dates with arbitrary precision, e.g. to the nearest 15 minutes or every 3 hours: nearest_three_hours = floor_date(now(), '3 hours') There's a discussion of such

When is it ok to store datetimes as local time rathen than UTC?

主宰稳场 提交于 2021-02-04 16:47:37
问题 This is a question similar to this one. I'm really tempted to store datetimes in my app as local time rather than as UTC (which is considered a best practice). In the app I have a number of events happening, each assigned to a given location. Always when I display them to the user, I want to show the local time of the event. I.e.: ==================================================================================== Event time (with TZ) | As UTC | As local time | To be displayed | =============

When is it ok to store datetimes as local time rathen than UTC?

久未见 提交于 2021-02-04 16:47:22
问题 This is a question similar to this one. I'm really tempted to store datetimes in my app as local time rather than as UTC (which is considered a best practice). In the app I have a number of events happening, each assigned to a given location. Always when I display them to the user, I want to show the local time of the event. I.e.: ==================================================================================== Event time (with TZ) | As UTC | As local time | To be displayed | =============

How to count concurrent events in a dataframe in one line?

做~自己de王妃 提交于 2021-02-04 16:09:42
问题 I have a dataset with phone calls. I want to count how many active calls there are for each record. I found this question but I'd like to avoid loops and functions. Each call has a date , a start time and a end time . The dataframe: start end date 0 09:17:12 09:18:20 2016-08-10 1 09:15:58 09:17:42 2016-08-11 2 09:16:40 09:17:49 2016-08-11 3 09:17:05 09:18:03 2016-08-11 4 09:18:22 09:18:30 2016-08-11 What I want: start end date activecalls 0 09:17:12 09:18:20 2016-08-10 1 1 09:15:58 09:17:42

How to count concurrent events in a dataframe in one line?

天大地大妈咪最大 提交于 2021-02-04 16:08:43
问题 I have a dataset with phone calls. I want to count how many active calls there are for each record. I found this question but I'd like to avoid loops and functions. Each call has a date , a start time and a end time . The dataframe: start end date 0 09:17:12 09:18:20 2016-08-10 1 09:15:58 09:17:42 2016-08-11 2 09:16:40 09:17:49 2016-08-11 3 09:17:05 09:18:03 2016-08-11 4 09:18:22 09:18:30 2016-08-11 What I want: start end date activecalls 0 09:17:12 09:18:20 2016-08-10 1 1 09:15:58 09:17:42

How to count concurrent events in a dataframe in one line?

99封情书 提交于 2021-02-04 16:08:38
问题 I have a dataset with phone calls. I want to count how many active calls there are for each record. I found this question but I'd like to avoid loops and functions. Each call has a date , a start time and a end time . The dataframe: start end date 0 09:17:12 09:18:20 2016-08-10 1 09:15:58 09:17:42 2016-08-11 2 09:16:40 09:17:49 2016-08-11 3 09:17:05 09:18:03 2016-08-11 4 09:18:22 09:18:30 2016-08-11 What I want: start end date activecalls 0 09:17:12 09:18:20 2016-08-10 1 1 09:15:58 09:17:42

Converting date string with timezone to epoch

蹲街弑〆低调 提交于 2021-02-04 16:08:37
问题 I'm trying to convert this date string including timezone to epoch time. (python 2.7) Mon, 08 Jun 2009 19:37:51 GMT I tried to do so like that: from dateutil import parser parser.parse("Mon, 08 Jun 2009 19:37:51 GMT").strftime('%s') The error I get is: ValueError: Invalid format string What is the problem? How can it be fixed? Thanks. 回答1: Python 3.5 solution using timestamp() method: from dateutil import parser print(parser.parse("Mon, 08 Jun 2009 19:37:51 GMT").timestamp()) which yields:

How to count concurrent events in a dataframe in one line?

▼魔方 西西 提交于 2021-02-04 16:08:20
问题 I have a dataset with phone calls. I want to count how many active calls there are for each record. I found this question but I'd like to avoid loops and functions. Each call has a date , a start time and a end time . The dataframe: start end date 0 09:17:12 09:18:20 2016-08-10 1 09:15:58 09:17:42 2016-08-11 2 09:16:40 09:17:49 2016-08-11 3 09:17:05 09:18:03 2016-08-11 4 09:18:22 09:18:30 2016-08-11 What I want: start end date activecalls 0 09:17:12 09:18:20 2016-08-10 1 1 09:15:58 09:17:42