问题
I have found the following method to downsample a signal in python. I would like to use this method with a sample_rate
of 100.21 but I think currently it only works for integer powers of two. Is there a possibility to downsample my signal with frequency 100.21 Hz to 8 Hz?
def interpolateDataTo8Hz(data,sample_rate,startTime):
# Downsample
idx_range = range(0,len(data))
data = data.iloc[idx_range[0::int(sample_rate)/8]]
# Set the index to be 8Hz
data.index = pd.DatetimeIndex(start=startTime,periods = len(data),freq='125L')
# Interpolate all empty values
data = interpolateEmptyValues(data)
return data
def interpolateEmptyValues(data):
cols = data.columns.values
for c in cols:
data[c] = data[c].interpolate()
return data
来源:https://stackoverflow.com/questions/50301330/downsampling-signal-from-100-21-hz-to-8-hz-non-integer-decimation-factor