pyNetLogo icon indicating copy to clipboard operation
pyNetLogo copied to clipboard

AttributeError: 'DataFrame' object has no attribute 'ix'

Open johndehart opened this issue 3 years ago • 3 comments

I'm working through your introduction tutorial and I have hit a snag at item [13] for the patch report. When I execute the code its returning https://pynetlogo.readthedocs.io/en/latest/_docs/introduction.html

It looks like this may be related to versions of pandas > 1.0.0 (I have 1.2.4 installed). It was suggested to modify ix to loc or iloc []https://stackoverflow.com/questions/59991397/attributeerror-dataframe-object-has-no-attribute-ix

I updated 'patch_report' in pyNetLogo/core.py and its now working was: results_df.xi[:, :] = resultsvec.reshape(results_df.shape) is: results_df.iloc[:, :] = resultsvec.reshape(results_df.shape)

Let me know your thoughts... thanks

johndehart avatar May 21 '21 17:05 johndehart

exactly on which pynetlogo command do you get the error?

It seems that all references to ix have been removed from master, so it should be possible to release a new version of pynetlogo that fixes this issue.

quaquel avatar May 21 '21 18:05 quaquel

This issue starts with notebook cell [13] from []https://pynetlogo.readthedocs.io/en/latest/_docs/introduction.html

johndehart avatar May 24 '21 09:05 johndehart

Facing the same error when running netlogo.patch_report("countdown") (from the examples). I'm using pynetlogo 0.4.2 and pandas 1.4.3. Here's the stacktrace:

Traceback (most recent call last):
  File "/home/.../PycharmProjects/agent-based-modelling/netlogo_wolves.py", line 115, in <module>
    main()
  File "/home/.../PycharmProjects/agent-based-modelling/netlogo_wolves.py", line 97, in main
    countdown_df: pd.DataFrame = netlogo.patch_report("countdown")
  File "/home/.../anaconda3/envs/agent-based-modelling/lib/python3.10/site-packages/pyNetLogo/core.py", line 437, in patch_report
    results_df.ix[:, :] = resultsvec.reshape(results_df.shape)
  File "/home/.../anaconda3/envs/agent-based-modelling/lib/python3.10/site-packages/pandas/core/generic.py", line 5575, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'ix'

cptanalatriste avatar Jul 23 '22 13:07 cptanalatriste

All references to .ix are gone in master, and the notebooks run successfully.

quaquel avatar Mar 13 '23 07:03 quaquel