Skip to content

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

Closed
@1160054

Description

@1160054

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions