reduce time series based on sum condition
 reduce time series based on sum condition amdi40 Programmer named Tim Posts: 15 Threads: 6 Joined: Jan 2022 Reputation: 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? ```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)``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post How to accumulate volume of time series amdi40 3 1,353 Feb-15-2022, 02:23 PM Last Post: amdi40 Reduce four for loops or parallelizing code in Python cee878 1 762 Feb-10-2022, 10:02 AM Last Post: Larz60+ Pandas Data frame column condition check based on length of the value aditi06 1 1,856 Jul-28-2021, 11:08 AM Last Post: jefsummers Recommendations for ML libraries for time-series forecast AndreasPython 0 1,422 Jan-06-2021, 01:03 PM Last Post: AndreasPython Time Series forecating with multiple independent variables Krychol88 1 1,301 Oct-23-2020, 08:11 AM Last Post: DPaul how to handling time series data file with Python? aupres 4 2,052 Aug-10-2020, 12:40 PM Last Post: MattKahn13 Extracting rows based on condition on one column Robotguy 2 1,573 Aug-07-2020, 02:27 AM Last Post: Robotguy Changing Time Series from Start to End of Month illmattic 0 1,395 Jul-16-2020, 10:49 AM Last Post: illmattic HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,293 Jul-11-2020, 09:04 PM Last Post: bntayfur Differencing Time series and Inverse after Training donnertrud 0 3,198 May-27-2020, 06:11 AM Last Post: donnertrud

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020