resampling

bootstrap resampling for hierarchical/multilevel data

情到浓时终转凉″ 提交于 2019-12-08 05:36:07
问题 I am attempting to do bootstrap resampling on a multilevel/hierarchical dataset. The observations are (unique) patients clustered within hospitals. My strategy is to sample with replacement from the patients within each hospital in turn, which will ensure that all hospitals are represented in the sample and that when repeated all the samples sizes will be the same. This is method 2 here. My code is like this: hv <- na.omit(unique(dt$hospital)) samp.out <- NULL for (hosp in hv ) { ss1 <- dt[dt

Resampling dataframe by hours and date

不想你离开。 提交于 2019-12-08 03:58:01
问题 I have a dataframe like this: Maximum Demand (KVA) Consumption (KVAh) Power Factor Timestamp 2017-04-01 01:00:00 127.0 261.0 0.81 2017-04-01 02:00:00 133.0 268.0 0.79 2017-04-01 03:00:00 119.0 273.0 0.92 2017-04-01 04:00:00 118.0 263.0 0.78 2017-04-01 05:00:00 135.0 271.0 0.86 2017-04-01 06:00:00 130.0 257.0 0.82 2017-04-01 23:00:00 120.0 261.0 0.78 2017-04-02 00:00:00 121.0 272.0 0.83 2017-04-02 01:00:00 126.0 263.0 0.90 2017-04-02 02:00:00 132.0 266.0 0.83 2017-04-02 03:00:00 132.0 275.0 0

What is the correct method to upsample?

自古美人都是妖i 提交于 2019-12-07 18:28:02
问题 I have an array of samples at 75 Hz, and I want to store them at 128 Hz. If it was 64 Hz and 128 Hz it was very simple, I would just double all samples. But what is the correct way if the samplerates are not a fraction of eachother? 回答1: When you want to avoid Filtering then you can: handle signal as set of joined interpolation cubics curves but this point is the same as if you use linear interpolation. Without knowing something more about your signal and purpose you can not construct valid

resample Pandas dataframe and merge strings in column

我们两清 提交于 2019-12-06 10:53:03
I want to resample a pandas dataframe and apply different functions to different columns. The problem is that I cannot properly process a column with strings. I would like to apply a function that merges the string with a delimiter such as " - ". This is a data example: import pandas as pd import numpy as np idx = pd.date_range('2017-01-31', '2017-02-03') data=list([[1,10,"ok"],[2,20,"merge"],[3,30,"us"]]) dates=pd.DatetimeIndex(['2017-01-31','2017-02-03','2017-02-03']) d=pd.DataFrame(data, index=,columns=list('ABC')) A B C 2017-01-31 1 10 ok 2017-02-03 2 20 merge 2017-02-03 3 30 us Resampling

What is the correct method to upsample?

我们两清 提交于 2019-12-06 10:44:06
I have an array of samples at 75 Hz, and I want to store them at 128 Hz. If it was 64 Hz and 128 Hz it was very simple, I would just double all samples. But what is the correct way if the samplerates are not a fraction of eachother? When you want to avoid Filtering then you can: handle signal as set of joined interpolation cubics curves but this point is the same as if you use linear interpolation. Without knowing something more about your signal and purpose you can not construct valid coefficients (without damaging signal accuracy) for example of how to construct such cubic look here: my

Help with resampling/upsampling

限于喜欢 提交于 2019-12-06 06:30:42
问题 I have an array of 240 data points sampled at 600hz, representing 400ms. I need to resample this data to 512 data points sampled at 1024hz, representing 500ms. I assume since I'm starting with 400ms of data, the last 100ms will just need to be padded with 0s. Is there a best approach to take to accomplish this? 回答1: If you want to avoid interpolation then you need to upsample to a 76.8 kHz sample rate (i.e. insert 127 0s after every input sample), low pass filter, then decimate (drop 74 out

How can I add rows for all dates between two columns?

半城伤御伤魂 提交于 2019-12-05 07:05:46
import pandas as pd mydata = [{'ID' : '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016'}, {'ID' : '20', 'Entry Date': '10/10/2016', 'Exit Date': '18/10/2016'}] mydata2 = [{'ID': '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016', 'Date': '10/10/2016'}, {'ID': '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016', 'Date': '11/10/2016'}, {'ID': '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016', 'Date': '12/10/2016'}, {'ID': '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016', 'Date': '13/10/2016'}, {'ID': '10', 'Entry Date': '10/10/2016', 'Exit Date':

Resample in a rolling window using pandas

喜你入骨 提交于 2019-12-05 05:40:42
Assume I have daily data ( not regularly spaced ), I want to compute for each month the moving standard deviation (or an arbitrarily non linear function) in the past 5 months. For example, for May 2012 I would compute the stddev from the period starting from Jan 2012 to May 2012 (5 months). For June 2012 the period starts in Feb 2012, etc. The final result is a time series with monthly values. I cannot apply a rolling window because this would first be daily and secondly I need to specify the number of values (a rolling window does not aggregate by time frame, some posts addressed this issue

Pandas: Resample dataframe column, get discrete feature that corresponds to max value

故事扮演 提交于 2019-12-04 14:04:18
Sample data: import pandas as pd import numpy as np import datetime data = {'value': [1,2,4,3], 'names': ['joe', 'bob', 'joe', 'bob']} start, end = datetime.datetime(2015, 1, 1), datetime.datetime(2015, 1, 4) test = pd.DataFrame(data=data, index=pd.DatetimeIndex(start=start, end=end, freq="D"), columns=["value", "names"]) gives: value names 2015-01-01 1 joe 2015-01-02 2 bob 2015-01-03 4 joe 2015-01-04 3 bob I want to resample by '2D' and get the max value, something like: df.resample('2D') The expected result should be: value names 2015-01-01 2 bob 2015-01-03 4 joe Can anyone help me? You can

Help with resampling/upsampling

假如想象 提交于 2019-12-04 12:22:49
I have an array of 240 data points sampled at 600hz, representing 400ms. I need to resample this data to 512 data points sampled at 1024hz, representing 500ms. I assume since I'm starting with 400ms of data, the last 100ms will just need to be padded with 0s. Is there a best approach to take to accomplish this? If you want to avoid interpolation then you need to upsample to a 76.8 kHz sample rate (i.e. insert 127 0s after every input sample), low pass filter, then decimate (drop 74 out of every 75 samples). You can use windowed Sinc interpolation, which will give you the same result as