Python Forum
reduce time series based on sum condition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reduce time series based on sum condition
#1
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
  Help: Conversion of Electricity Data into Time Series Data SmallGuy 3 1,158 Oct-04-2023, 03:31 PM
Last Post: deanhystad
  Time Series Production Process Problem Mzarour 1 2,098 Feb-28-2023, 12:25 PM
Last Post: get2sid
  How to accumulate volume of time series amdi40 3 2,259 Feb-15-2022, 02:23 PM
Last Post: amdi40
  Reduce four for loops or parallelizing code in Python cee878 1 1,166 Feb-10-2022, 10:02 AM
Last Post: Larz60+
  Pandas Data frame column condition check based on length of the value aditi06 1 2,655 Jul-28-2021, 11:08 AM
Last Post: jefsummers
  Recommendations for ML libraries for time-series forecast AndreasPython 0 1,862 Jan-06-2021, 01:03 PM
Last Post: AndreasPython
  Time Series forecating with multiple independent variables Krychol88 1 1,823 Oct-23-2020, 08:11 AM
Last Post: DPaul
  how to handling time series data file with Python? aupres 4 2,925 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Extracting rows based on condition on one column Robotguy 2 2,172 Aug-07-2020, 02:27 AM
Last Post: Robotguy
  Changing Time Series from Start to End of Month illmattic 0 1,827 Jul-16-2020, 10:49 AM
Last Post: illmattic

Forum Jump:

User Panel Messages

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