Encode time-series of different lengths with keras
Figure out the max length you want your time series to be and use linear interpolation to fill in missing values in the shorter series so that time series can be same length.
Example of this is:
def interpolate_to_length(time_series, final_length):
    curr_ts_length = time_series.shape[1]
    idx = np.array(range(curr_ts_length))
    idx_new = np.linspace(0, idx.max(), final_length)
    # linear interpolation
    f = interp1d(idx, time_series, kind='cubic')
    new_ts = f(idx_new)
    return new_ts

df = pd.DataFrame(data = {'col1': [1, 5, 10, 15, 20], 'col2': [1, 6, 11, 13, 15]})
print(df)
transposed_values = df.values.transpose()
print(transposed_values)
print(interpolate_to_length(transposed_values, 10))


Output should be:
   col1  col2
0     1     1
1     5     6
2    10    11
3    15    13
4    20    15
[[ 1  5 10 15 20]
 [ 1  6 11 13 15]]
[[ 1.          2.5743027   4.48331047  6.61728395  8.86648377 11.12391404
  13.34567901 15.55098308 17.76177412 20.        ]
 [ 1.          2.93415638  5.36213992  7.88888889 10.11934156 11.67489712
  12.55555556 13.1399177  13.82304527 15.        ]]