Apr-06-2022, 09:09 AM
Hello i am trying to reduce the amount of zeros in a timeseries as i only need a period of 24 hour without rain before the condition does not change
The script so far looks like this, but the amount of time it takes to run through this is way too long. Is there someway i can make it faster?
The script so far looks like this, but the amount of time it takes to run through this is way too long. Is there someway i can make it faster?
import numpy as np
import pandas as pd
df_regn = pd.read_csv('rain_series_raw.csv', parse_dates=True, index_col=0, sep=",")
n_sim = len(df_regn) # Antal tidskridt der skal simuleres
total = np.zeros((n_sim))
df = np.zeros((n_sim))
for i in range(1, n_sim):
total[i] = sum(df_regn.iloc[i:i - 1400, 0])
if total[i] > 0.1:
df[i] = df_regn[i]
else:
df[i] = 5001
np.savetxt("regn23.csv", total)
