time-series

How to use apply_ufunc with numpy.digitize for each image along time dimension of xarray.DataArray?

雨燕双飞 提交于 2020-02-24 05:44:20
问题 I've rephrased my earlier question substantially for clarity. Per Ryan's suggestion on a separate channel, numpy.digitize looks is the right tool for my goal. I have of an xarray.DataArray of shape x, y, and time. I've trying to puzzle out what values I should supply to the apply_ufunc function's 'input_core_dims' and 'output_core_dims' arguments in order to apply numpy.digitize to each image in the time series. Intuitively, I want the output dimensions to be ['time', 'x', 'y']. I think the

Difference pandas.DateTimeIndex without a frequency

冷暖自知 提交于 2020-02-23 09:25:09
问题 An irregular time series data is stored in a pandas.DataFrame . A DatetimeIndex has been set. I need the time difference between consecutive entries in the index. I thought it would be as simple as data.index.diff() but got AttributeError: 'DatetimeIndex' object has no attribute 'diff' I tried data.index - data.index.shift(1) but got ValueError: Cannot shift with no freq I do not want to infer or enforce a frequency first before doing this operation. There are large gaps in the time series

Difference pandas.DateTimeIndex without a frequency

坚强是说给别人听的谎言 提交于 2020-02-23 09:24:26
问题 An irregular time series data is stored in a pandas.DataFrame . A DatetimeIndex has been set. I need the time difference between consecutive entries in the index. I thought it would be as simple as data.index.diff() but got AttributeError: 'DatetimeIndex' object has no attribute 'diff' I tried data.index - data.index.shift(1) but got ValueError: Cannot shift with no freq I do not want to infer or enforce a frequency first before doing this operation. There are large gaps in the time series

Header names as dates in r

自闭症网瘾萝莉.ら 提交于 2020-02-23 04:28:04
问题 I'm trying to calculate the "death" of users, meaning I want to determine the time duration between when a user signs up for a program and when they are no longer active in the program. I have two files which I read in using read.csv("filename",header=TRUE) : > df name start.date 1 Allison 2013-03-16 2 Andrew 2013-03-16 3 Carl 2013-03-16 4 Dora 2013-03-17 5 Hilary 2013-03-17 6 Louis 2013-03-19 7 Mary 2013-03-20 8 Mickey 2013-03-20 And file 2: > df2 names X04.16.2013 X04.17.2013 X04.18.2014

How do find correlation between time events and time series data in python?

ぃ、小莉子 提交于 2020-02-16 05:28:30
问题 I have two different excel files. One of them is including time series data (268943 accident time rows) as below Datetime 0 2010-01-01 14:00:00 1 2010-01-01 13:00:00 2 2010-01-01 21:00:00 3 2010-01-01 13:00:00 4 2010-01-01 21:00:00 ... ... 268938 2018-08-06 11:25:00 268939 2018-08-06 10:30:00 268940 2018-08-06 10:00:00 268941 2018-08-06 11:37:00 268942 2018-08-06 09:00:00 [268943 rows x 1 columns] dtype = datetime64[ns] The other file is blood sugar level of 14 workers measured daily from 8

Effects of Education Spending on Crime, multi-level mixed-model structure

不问归期 提交于 2020-02-07 04:04:49
问题 I’m looking at the effect of education_expenditure per school district on crime rate within the cities and towns those school districts serve over a fifteen year period. (The DV has 1,676,191 observations of city/town crime data over those fifteen years). Cities are technically crossed with school district, in that one city might attend multiple school districts. This means that one city could have multiple values for expenditure per student. School districts, however, overlap with counties.

Use dplyr to summarize but preserve date of group row

北慕城南 提交于 2020-02-07 01:59:13
问题 I have a data frame like the following: Date Flare Painmed_Use 1 2015-12-01 0 0 2 2015-12-02 0 0 3 2015-12-03 0 0 4 2015-12-04 0 0 5 2015-12-05 0 0 6 2015-12-06 0 1 7 2015-12-07 1 4 8 2015-12-08 1 3 9 2015-12-09 1 1 10 2015-12-10 1 0 11 2015-12-11 0 0 12 2015-12-12 0 0 13 2015-12-13 1 2 14 2015-12-14 1 3 15 2015-12-15 1 1 16 2015-12-16 0 0 I'm trying to find the length of each flare as well as the total med use during each flare using dplyr. My current solution (inspired by Use rle to group

Python Pandas: weekly columns(int) to Timestamp columns conversion (in weeks)

孤人 提交于 2020-02-05 13:10:53
问题 I have a df with weekly columns as below. I want to change my column index to timestamp. Here is my df.columns df.columns: Int64Index([201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, ...], dtype='int64', name='timeline', length=104) df.columns[0]: 201553 I want to change my df.columns into timestamp as below df.columns: DatetimeIndex(['2016-01-04', '2016-01-11', '2016-01-18', '2016-01-25', '2016-02-01', '2016-02-08', '2016-02-15', '2016-02-22', '2016-02-29'.....],

Python Pandas: weekly columns(int) to Timestamp columns conversion (in weeks)

这一生的挚爱 提交于 2020-02-05 13:07:55
问题 I have a df with weekly columns as below. I want to change my column index to timestamp. Here is my df.columns df.columns: Int64Index([201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, ...], dtype='int64', name='timeline', length=104) df.columns[0]: 201553 I want to change my df.columns into timestamp as below df.columns: DatetimeIndex(['2016-01-04', '2016-01-11', '2016-01-18', '2016-01-25', '2016-02-01', '2016-02-08', '2016-02-15', '2016-02-22', '2016-02-29'.....],

How to perform R time based resampling with a given time period equivalently to using pandas 'resample' functions?

久未见 提交于 2020-02-05 08:14:06
问题 I am trying to find a way to do the equivalent re-sampling action as the pandas manipulation below: example original dataframe df: FT Time 2017-03-18 23:30:00 73.9 2017-03-18 23:31:00 73.5 2017-03-18 23:32:00 71.6 2017-03-18 23:33:00 71.3 2017-03-18 23:34:00 72.3 2017-03-18 23:35:00 72.1 2017-03-18 23:36:00 70.1 2017-03-18 23:37:00 67.9 2017-03-18 23:38:00 65.4 2017-03-18 23:39:00 63.4 2017-03-18 23:40:00 61.3 2017-03-18 23:41:00 59.9 2017-03-18 23:42:00 58.4 2017-03-18 23:43:00 58.4 2017-03