Skip to content

Commit

Permalink
Fix frequency inference if NaT (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaiBe-ctrl authored Jun 21, 2024
1 parent 711b30a commit d4e2553
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions neuralprophet/df_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,13 @@ def _infer_frequency(df, freq, min_freq_percentage=0.7):
frequencies, distribution = get_freq_dist(df["ds"])
argmax_frequency = frequencies[np.argmax(distribution)]

if np.isnan(argmax_frequency):
if freq == "auto" or freq is None:
log.warning("The auto-frequency feature is not able to detect the frequency. Please define it manually.")
raise ValueError("Cannot infer frequency")
else:
return freq

# exception - monthly df (28, 29, 30 or 31 days freq)
MONTHLY_FREQUENCIES = [2.4192e15, 2.5056e15, 2.5920e15, 2.6784e15]
if argmax_frequency in MONTHLY_FREQUENCIES:
Expand Down

0 comments on commit d4e2553

Please sign in to comment.