arundo / adtk

A Python toolkit for rule-based/unsupervised anomaly detection in time series
https://adtk.readthedocs.io
Mozilla Public License 2.0
1.08k stars 145 forks source link

pandas removed deprecated `Series.iteritems()`, `DataFrame.iteritems()`, use `obj.items` instead #147

Open Xiaoshu-Zhao opened 1 year ago

Xiaoshu-Zhao commented 1 year ago

pandas removed deprecated Series.iteritems(), DataFrame.iteritems() but in _data.py you still used iteritems. For example, in line 164 for t, v in time_window_end_series.iteritems(): please change it to items

VladimirFokow commented 1 year ago

This is also the reason why the plot function with anomaly_tag="span" (the default value) produces AttributeError: 'Series' object has no attribute 'iteritems'

(because: anomaly=anomalies : pd.Series).

For example, the plot line here would now produce an error: https://adtk.readthedocs.io/en/stable/notebooks/demo.html#PersistAD

s = pd.read_csv('./data/price_short.csv', index_col="Time", parse_dates=True, squeeze=True)
s = validate_series(s)

from adtk.detector import PersistAD
persist_ad = PersistAD(c=3.0, side='positive')
anomalies = persist_ad.fit_detect(s)
plot(s, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_color='red');
khadijahafeez commented 4 months ago

This is also the reason why the plot function with anomaly_tag="span" (the default value) produces AttributeError: 'Series' object has no attribute 'iteritems'

(because: anomaly=anomalies : pd.Series).

For example, the plot line here would now produce an error: https://adtk.readthedocs.io/en/stable/notebooks/demo.html#PersistAD

How do I fix this issue, the error is indicating in _plot_anomaly function in _visualization.py