ydata-profiling: TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

    stats['range'] = stats['max'] - stats['min']
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

I got this error

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

In base.py file, go to line number 59. Change stats['range'] = stats['max'] - stats['min'] to stats['range'] = np.subtract(stats['max'], stats['min'], dtype=np.float32) and report the results.

Stale issue

@jvschoen thank you for reporting this issue. This is a specific GCP issue. In a local environment, the code seems to work just fine:

# As features on the Google Cloud Platform website:
# https://cloud.google.com/solutions/building-a-propensity-model-for-financial-services-on-gcp


import pandas as pd

from pandas_profiling import ProfileReport


if __name__ == "__main__":
    df = pd.read_csv('https://storage.googleapis.com/erwinh-public-data/bankingdata/bank-full.csv', sep=';')

    profile = ProfileReport(df, title="GCP Banking Data")
    profile.to_file('gcp_banking_report.html', silent=False)

Solution for GCP Jupyterlab: There is a solution for the GCP notebook.

  1. Make sure the you have the latest version of pandas-profiling installed. You can achieve this by replacing the pip install in the first cell with:
!pip install --user -U pandas-profiling

Make sure you restart the kernel.

You can verify the version using:

from pandas_profiling.version import __version__
print(__version__)
  1. Replace
import pandas_profiling as pp
pp.ProfileReport(df)

with

import pandas_profiling as pp
report = pp.ProfileReport(df)
report.to_notebook_iframe()

Enabeling widgets

The widget inferface might need some extra steps to work:

  • Install using !pip install --user -U pandas-profiling[notebook]
  • Enable the jupyter widgets: sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager
  • Refresh the page and restart the kernel.

You can then run this code:

import pandas_profiling as pp
pp.ProfileReport(df)

Yes I believe this solves the problem!

@eyadsibai Does it work? I couldn’t reproduce the results. So, bear with me for some manual editing.