resampling

Pandas OHLC aggregation on OHLC data

Pandas OHLC aggregation on OHLC data Question: I understand that OHLC re-sampling of time series data in Pandas, using one column of data, will work perfectly, for example on the following dataframe: >>df ctime openbid 1443654000 1.11700 1443654060 1.11700 … df[‘ctime’] = pd.to_datetime(df[‘ctime’], unit=’s’) df = df.set_index(‘ctime’) df.resample(‘1H’, how=’ohlc’, axis=0, fill_method=’bfill’) >>> open high low …

Total answers: 5

Resample a numpy array

Resample a numpy array Question: It’s easy to resample an array like a = numpy.array([1,2,3,4,5,6,7,8,9,10]) with an integer resampling factor. For instance, with a factor 2 : b = a[::2] # [1 3 5 7 9] But with a non-integer resampling factor, it doesn’t work so easily : c = a[::1.5] # [1 2 3 …

Total answers: 5

Pandas.resample to a non-integer multiple frequency

Pandas.resample to a non-integer multiple frequency Question: I have to resample my dataset from a 10-minute interval to a 15-minute interval to make it in sync with another dataset. Based on my searches at stackoverflow I have some ideas how to proceed, but none of them deliver a clean and clear solution. Problem Problem set …

Total answers: 3

Pandas every nth row

Pandas every nth row Question: Dataframe.resample() works only with timeseries data. I cannot find a way of getting every nth row from non-timeseries data. What is the best method? Asked By: mikael || Source Answers: I’d use iloc, which takes a row/column slice, both based on integer position and following normal python syntax. If you …

Total answers: 7