Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I encountered a strange error when using adtk's plot method: ValueError: Multi-dimensional indexing (e.g. obj[:, None]) is no longer supported. Convert to a numpy array before indexing instead #150

Open
TonyEinstein opened this issue Oct 8, 2023 · 0 comments

Comments

@TonyEinstein
Copy link

My code is:

`
df = pd.read_csv('cleaned_data/原始值-周均价.csv')
df['date'] = pd.to_datetime(df['date'])
df.set_index('date',inplace=True)
df = validate_series(df)

from adtk.data import validate_series
from adtk.visualization import plot
from adtk.transformer import RollingAggregate
from adtk.transformer import DoubleRollingAggregate
from adtk.detector import ThresholdAD
threshold_ad = ThresholdAD(high=10, low=5)
anomalies = threshold_ad.detect(df)

plot(df, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=5, anomaly_color='red', anomaly_tag="marker");
`

I encountered an error:

`
ValueError Traceback (most recent call last)
Cell In[25], line 18
13 threshold_ad = ThresholdAD(high=10, low=5)
14 anomalies = threshold_ad.detect(df)
---> 18 plot(df, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=5, anomaly_color='red', anomaly_tag="marker");

File ~\anaconda3\envs\d2l\lib\site-packages\pandas\core\indexers\utils.py:341, in disallow_ndim_indexing(result)
333 """
334 Helper function to disallow multi-dimensional indexing on 1D Series/Index.
335
(...)
338 in GH#30588.
339 """
340 if np.ndim(result) > 1:
--> 341 raise ValueError(
342 "Multi-dimensional indexing (e.g. obj[:, None]) is no longer "
343 "supported. Convert to a numpy array before indexing instead."
344 )

ValueError: Multi-dimensional indexing (e.g. obj[:, None]) is no longer supported. Convert to a numpy array before indexing instead.
`

My version information:

adtk==0.6.2

I have made the following solutions, but none of them can be solved:

  1. I asked chatgpt, and it told me to switch to an array, but although I knew that the plot method required df, I still tried an array, and it was really an error.

I can't solve this problem. The great open source tycoon can give me some suggestions or solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant