resampling

Alternatives to python griddata

允我心安 提交于 2020-01-15 17:38:14
问题 I am using griddata to resample a numpy 2 dimensional array on a grid. z.shape = (1000, 1000) x, y = np.arange(-5, 5, 0.01), np.arange(-5, 5, 0.01) newx, newy = np.arange(-2, 2, 0.1), np.arange(-2, 2, 0.1) griddata((x, y), z, (newx[None, :], newy[:, None])) The code should: resample z (which represents an image) to a new coarser or finer grid the new grid does not necessarily cover all of the original one. However griddata cannot manage a regular input grid. Does anyone know an easy

Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'

亡梦爱人 提交于 2020-01-11 10:49:13
问题 I'm trying to resample this Timestamp column of this Dataframe: Transit.head(): Timestamp Plate Gate 0 2013-11-01 21:02:17 4f5716dcd615f21f658229a8570483a8 65 1 2013-11-01 16:12:39 0abba297ac142f63c604b3989d0ce980 64 2 2013-11-01 11:06:10 faafae756ce1df66f34f80479d69411d 57 And Here's What I've Done: Transit.drop_duplicates(inplace=True) Transit.Timestamp = pd.to_datetime(Transit.Timestamp) Transit['Timestamp'].resample('1H').pad() But I got This Error: Only valid with DatetimeIndex,

resample an image from pixel to millimiters

亡梦爱人 提交于 2020-01-06 01:16:08
问题 I have an image (logical values), like this I need to get this image resampled from pixel to mm or cm; this is the code I use to get the resampling: function [ Ires ] = imresample3( I, pixDim ) [r,c]=size(I); x=1:1:c; y=1:1:r; [X,Y]=meshgrid(x,y); rn=r*pixDim; cn=c*pixDim; xNew=1:pixDim:cn; yNew=1:pixDim:rn; [Xnew,Ynew]=meshgrid(xNew,yNew); Id=double(I); Ires=interp2(X,Y,Id,Xnew,Ynew); end What I get is a black image. I suspect that this code does something that is not what I have in mind: it

Resample/fill gaps for blocks of datetime stamps

心不动则不痛 提交于 2020-01-05 05:54:31
问题 Problem I put a csv to a dataframe where some datetime gaps are present - sample frequency is 15 min, for each datetimestamps there is always a block of three values. In this example the block for the datetime 2017-12-11 23:15:00 is missing. ID Datetime Value 0 a 2017-12-11 23:00:00 20.0 1 b 2017-12-11 23:00:00 20.9 2 c 2017-12-11 23:00:00 21.0 3 a 2017-12-11 23:30:00 19.8 4 b 2017-12-11 23:30:00 20.8 5 c 2017-12-11 23:30:00 20.8 Desired result What I want to do is to resample the Datetime

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

与世无争的帅哥 提交于 2020-01-01 16:42:28
问题 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')

Efficient algorithm for generating unique (non-repeating) random numbers

空扰寡人 提交于 2019-12-30 10:39:06
问题 I want to solve the following problem. I have to sample among an extremely large set, of the order of 10^20 and extracting a sample without repetitions of size about 10%-20%. Given the size of the set, I believe that an algorithm like Fisher–Yates is not feasible. I'm thinking that something like random path tree might work for doing it in O(n log n) and can't be done faster, but I want to ask if something like this has already been implemented. Thank you for your time! 回答1: I don't know how

Resample pandas dataframe only knowing result measurement count

旧时模样 提交于 2019-12-25 05:33:15
问题 I have a dataframe which looks like this: Trial Measurement Data 0 0 12 1 4 2 12 1 0 12 1 12 2 0 12 1 12 2 NaN 3 12 I want to resample my data so that every trial has just two measurements So I want to turn it into something like this: Trial Measurement Data 0 0 8 1 8 1 0 12 1 12 2 0 12 1 12 This rather uncommon task stems from the fact that my data has an intentional jitter on the part of the stimulus presentation. I know pandas has a resample function, but I have no idea how to apply it to

Resampling of time signal in MATLAB

佐手、 提交于 2019-12-24 07:50:08
问题 I want to resample my signal with to new time. Currently the sampling time of my signal is 0.01s , and the size of my signal and time array is 1*90001 . I am trying to use resample(x,p,q) in MATLAB, but I am a little bit confused. Can somebody suggest the right way to use this function and how to resample my data to rate of 0.02s instead of 0.01s ? Code - this is how I am trying to use resample , with example data. t = [0:0.03:1]; x = sin(4*pi*t); y = resample(x, 1, 2); ty = resample(t,1,2);

Resample and looping over dplyr functions in R

蓝咒 提交于 2019-12-24 07:37:48
问题 I have the following data-set (dat) with 8 unique treatment groups. I want to sample 3 points from each unique group and store their mean and variance. I want to do this 1000 times over (sample with replacement) using a loop to store all the values in output. I tried to do this loop and I keep running into unexpected '=' in:"output[i] <- summarise(group_by(new_df[i], fertilizer,crop, level),mean[i]=" Any suggestions on how to fix it, or make it more fertilizer <- c("N","N","N","N","N","N","N"

Pandas resample time series counting backwards (or reverse resample)

*爱你&永不变心* 提交于 2019-12-24 00:22:11
问题 I want to resample a pandas time series counting backwards. For example, let's set up a simple time series of 11 days: >>> index = pd.date_range('01-01-2018', '01-11-2018', freq='D') >>> randint = np.random.randint(low=0, high=9, size=(len(index), 1)) >>> df = pd.DataFrame(randint, index=index, columns=['random']) >>> print(df) random 2018-01-01 8 2018-01-02 8 2018-01-03 1 2018-01-04 4 2018-01-05 3 2018-01-06 5 2018-01-07 2 2018-01-08 6 2018-01-09 5 2018-01-10 1 2018-01-11 3 Default pandas