I\'m looking for a pandas equivalent of the resample method for a dataframe whose isn\'t a DatetimeIndex but an array of integers, or maybe even fl
Alternative, this is one thing that can be done
def resample(df, rule, how=None, **kwargs):
import pandas as pd
if how==None:
import numpy as np
how = np.mean
if isinstance(df.index, pd.DatetimeIndex) and isinstance(rule, str):
return df.resample(rule, how, **kwargs)
else:
idx, bins = pd.cut(df.index, range(df.index[0], df.index[-1]+2, rule), right=False, retbins=True)
aux = df.groupby(idx).apply(how)
aux = aux.set_index(bins[:-1])
return aux