Skip to content

Commit b5421c8

Browse files
committed
Remove deprecated usage of Series.nonzero()
Series.nonzero() was deprecated in pandas-dev/pandas#24048. Using the latest pandas breaks fbprophet. We can replace .nonzero() use with .to_numpy().nonzero().
1 parent 57990e6 commit b5421c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/fbprophet/forecaster.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,11 @@ def set_auto_seasonalities(self):
942942
first = self.history['ds'].min()
943943
last = self.history['ds'].max()
944944
dt = self.history['ds'].diff()
945-
min_dt = dt.iloc[dt.values.nonzero()[0]].min()
945+
try:
946+
min_dt = dt.iloc[dt.values.nonzero()[0]].min()
947+
except AttributeError:
948+
# Series.nonzero() was removed in pandas 0.24rc1
949+
min_dt = dt.iloc[dt.values.to_numpy().nonzero()[0]].min()
946950

947951
# Yearly seasonality
948952
yearly_disable = last - first < pd.Timedelta(days=730)

0 commit comments

Comments
 (0)