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

[Bug Report] FutureWarning: np.object is deprecated in NumPy 1.20+ #4827

Closed
1160054 opened this issue Mar 2, 2025 · 0 comments
Closed

[Bug Report] FutureWarning: np.object is deprecated in NumPy 1.20+ #4827

1160054 opened this issue Mar 2, 2025 · 0 comments

Comments

@1160054
Copy link

1160054 commented Mar 2, 2025

Link to the notebook
bias-detection-explanability/fairness_and_explainability.ipynb

Describe the bug
When running the script with NumPy 1.20+, an AttributeError occurs due to the removal of np.object.
This happens in the number_encode_features() function when checking column data types:

if result.dtypes[column] == np.object:

Since np.object was deprecated in NumPy 1.20 and completely removed in later versions, this check causes an error.

To reproduce

  1. Use a Python environment with NumPy 1.20 or later.
  2. Run the script that calls number_encode_features().
  3. The following error will be raised:
AttributeError: module 'numpy' has no attribute 'object'

Logs
When executing the script, a FutureWarning might appear before the error occurs:

/tmp/ipykernel_596/1535508334.py:8: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  if result.dtypes[column] == np.object:

Then, the script will fail with:

/tmp/ipykernel_596/1535508334.py:8: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  if result.dtypes[column] == np.object:

AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself.
@1160054 1160054 closed this as completed Mar 2, 2025
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