intervals

How to join integers intervals in python?

时光怂恿深爱的人放手 提交于 2020-01-14 13:43:48
问题 I have used the module intervals (http://pyinterval.readthedocs.io/en/latest/index.html) And created an interval from a set or start, end tuples: intervals = interval.interval([1,8], [7,10], [15,20]) Which result in interval([1.0, 10.0], [15.0, 20.0]) as the [1,8] and [7,10] overlaps. But this module interprets the values of the pairs as real numbers, so two continuous intervals in integers will not be joined together. Example: intervals = interval.interval([1,8], [9,10], [11,20]) results in:

Union and intersection of intervals

醉酒当歌 提交于 2020-01-14 07:55:08
问题 I have a group of intervals for different ids. For example: df <- data.frame(id=c(rep("a",4),rep("b",2),rep("c",3)), start=c(100,250,400,600,150,610,275,600,700), end=c(200,300,550,650,275,640,325,675,725)) The intervals of each id do not overlap but the intervals of the different ids may overlap. Here is a picture: plot(range(df[,c(2,3)]),c(1,nrow(df)),type="n",xlab="",ylab="",yaxt="n") for ( ii in 1:nrow(df) ) lines(c(df[ii,2],df[ii,3]),rep(nrow(df)-ii+1,2),col=as.numeric(df$id[ii]),lwd=2)

Get time interval in mysql

浪尽此生 提交于 2020-01-14 07:40:07
问题 is there a query for me to get the time interval - One minute, five minutes, quarter hour, half hour, hour, and day? I use MySQL as a database. 回答1: to get a range, like from 30 to 45 minutes ago, do like this SELECT * FROM tbl WHERE tbl.mydate > DATE(DATE_sub(NOW(), INTERVAL 45 MINUTE)) AND tbl.mydate < DATE(DATE_sub(NOW(), INTERVAL 30 MINUTE)); 回答2: You are probably looking for date_sub: SELECT * FROM YOURTABLE t WHERE t.timestamp > date_sub(NOW(), interval 1 hour); For different intervals

Inner_join with two conditions and interval within interval condition

让人想犯罪 __ 提交于 2020-01-14 01:33:07
问题 Trying to join 2 dataframes according to multiple conditions and time interval condition like in the following example: # two sample dataframes with time intervals df1 <- data.frame(key1 = c("a", "b", "c", "d", "e"), key2 = c(1:5), time1 = as.POSIXct(hms::as.hms(c("00:00:15", "00:15:15", "00:30:15", "00:40:15", "01:10:15"))), time2 = as.POSIXct(hms::as.hms(c("00:05:15", "00:20:15", "00:35:15", "00:45:15", "01:15:15")))) %>% mutate(t1 = interval(time1, time2)) %>% select(key1, key2, t1) df2 <-

android locationManager requestLocationUpdates

若如初见. 提交于 2020-01-13 07:23:30
问题 Is there a way to request location updates from a locationManager at specific intervan and to ignore minDistance? I've tried locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3600 * 1000, 1, this) But in logs appears sometimes that location is updated in a few minutes, sometimes in a half of hour... Can this be done to update location at a fixed interval and to ignore distance? 回答1: You can use this schema. Create new Runnable which will be called every time, when you want

Android set repeating alarm for certain time of day

我怕爱的太早我们不能终老 提交于 2020-01-11 11:16:48
问题 I am trying to set a repeating alarm that will will download a file every minute but only between 8:00 and 22:00. I feel like I'm really close but I can't see the error I'm making. Currently the broadcast receiver is not activating. If set the repeating alarm manually to alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+10000, 60000,pendingIntent); it works fine. Any guidance would be much appreciated. protected void scheduleNextUpdate() { Intent intent = new

merge two data frames on non overlapping intervals

此生再无相见时 提交于 2020-01-10 06:08:46
问题 I want to merge two data frames. Both of them have a begin date and an end date. If the given intervals are overlapping, I want to split the resulting rows in non overlapping intevals. Please see this example: a id beg_a end_a prop_a 1 2000-01-01 2002-12-31 A 2 2000-01-01 2000-02-15 B 2 2000-04-01 2000-04-15 A 2 2002-01-01 2002-12-31 B 3 2000-01-01 2000-06-15 A b id beg_b end_b prop_b 1 1999-06-01 2000-05-15 D 1 2003-01-15 2003-01-31 D 2 1999-01-01 2003-01-15 D 3 2000-07-01 2001-08-01 E

Human-readable datetime interval to datetime.timedelta in Python?

情到浓时终转凉″ 提交于 2020-01-06 02:55:13
问题 I find myself needing to specify a timespan in a python configuration file a lot. Is there a way that I can specify a more human readable timeframe (similar to PostgreSQL's Interval syntax) in a python configuration file with stdlib? Or will this require a 3rd party lib? Clarification I'm not looking for anything in the ConfigParser.ConfigParser stdlib API specifically. I guess what I really need is a way to go from human readable date/time interval to datetime.timedelta value. 回答1: I don't

How to tweak the SET intervalstyle (change the Interval Output) in PostgreSQL?

白昼怎懂夜的黑 提交于 2020-01-05 19:29:27
问题 I have read in this online PostgreSQL documentation... http://www.postgresql.org/docs/9.4/static/datatype-datetime.html#INTERVAL-STYLE-OUTPUT-TABLE in the point 8.5.5 something about how to tweak the default Interval Output. . I mean the default interval is shown like this... 00:00:00.000 (if the timedifference is lower than a day or month or year) 1 day 00:00:00.000 (if the timedifference reaches days, but is lower than a month or a year) 1 month 1 day 00:00:00.000 (if the timediffence

Create while loop function that takes next largest value untill condition is met

天涯浪子 提交于 2020-01-05 08:25:07
问题 I want to create a function that creates a new column in a dataframe that starts with all 0's in all rows but will create 1's based on the following. It starts looking at the highest % in the percent column. That will produce a 1 in the newly created "algorithm" column in the same row. Then it will look at the minimum and maximum row of the starting row. Lets say the highest found (starting value) is 13,8% in row 6, the next rows that it will look at are 5 and 7. Then it will look at the