I have two Python lists of different lengths. It can be assumed that one of the lists is several times larger than the other.
Both lists contain the same physical data, but with different sampling frequencies.
My goal is to reduce the size of the larger signal so that it has exactly as many data points as there are less.
I came up with the following code that basically does this work, but not very pythonic and not able to handle very large lists in its own way:
import math
a = [1,2,3,4,5,6,7,8,9,10]
b = [1,4.5,6.9]
if len(a) > len(b):
div = int(math.floor(len(a)/len(b)))
a = a[::div]
diff = len(a)-len(b)
a = a[:-diff]
else:
div = int(math.floor(len(b)/len(a)))
b = b[::div]
diff = len(b)-len(a)
b = b[:-diff]
print a
print b
I would appreciate it if more experienced Python users could develop alternative ways to solve this problem.
Any response or comment is greatly appreciated.