I'm calculating EWMA values for array of streamflow, and code is like below:
import polars as pl
import numpy as np
streamflow_data = np.arange(0, 20, 1)
adaptive_alphas = np.concatenate([np.repeat(0.3, 10), np.repeat(0.6, 10)])
streamflow_series = pl.Series(streamflow_data)
ewma_data = np.zeros_like(streamflow_data)
for i in range(1, len(streamflow_series)):
current_alpha = adaptive_alphas[i]
ewma_data[i] = streamflow_series[:i+1].ewm_mean(alpha=current_alpha)[-1]
# When set dtype of ewma_data to float when initial it, output is like this
Output: [0 0.58823529 1.23287671 1.93051717 2.67678771 3.46668163, 4.29488309 5.1560635 6.04512113 6.95735309 9.33379473 10.33353466, 11.33342058 12.33337091 13.33334944 14.33334021 15.33333625 16.33333457, 17.33333386 18.33333355]
# When I don't point dtype of ewma_data and dtype of streamflow_data is int, output will be floored
Output: [0 0 1 1 2 3 4 5 6 6 9 10 11 12 13 14 15 16 17 18]
But when length of streamflow_data is very big (such as >100000), this code will become very slow.
So how can I extinguish for in my code and don't influence its result?
Hope for your reply.

np.zeros_like(streamflow_data, dtype=float)then you'll have float results inewma_data- and then results are the same as in my code