We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Potential incompatiblity with Pandas 1.4.0
**Describe the bug**

Pandas version 1.4.0 was release few days ago and some tests start failing. I was able to reproduce with a minimum example which is failing with Pandas 1.4.0 and working with Pandas 1.3.5.

**To Reproduce**

```python
import pandas as pd
import pandas_profiling

data = {"col1": [1, 2], "col2": [3, 4]}
dataframe = pd.DataFrame(data=data)

profile = pandas_profiling.ProfileReport(dataframe, minimal=False)
profile.to_html()
```

When running with Pandas 1.4.0, I get the following traceback:

```
Traceback (most recent call last):
  File "/tmp/bug.py", line 8, in <module>
    profile.to_html()
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py", line 368, in to_html
    return self.html
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py", line 185, in html
    self._html = self._render_html()
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py", line 287, in _render_html
    report = self.report
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py", line 179, in report
    self._report = get_report_structure(self.config, self.description_set)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py", line 161, in description_set
    self._description_set = describe_df(
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/describe.py", line 71, in describe
    series_description = get_series_descriptions(
  File "/vemv/lib/python3.9/site-packages/multimethod/__init__.py", line 303, in __call__
    return func(*args, **kwargs)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py", line 92, in pandas_get_series_descriptions
    for i, (column, description) in enumerate(
  File "/home/lothiraldan/.pyenv/versions/3.9.1/lib/python3.9/multiprocessing/pool.py", line 870, in next
    raise value
  File "/home/lothiraldan/.pyenv/versions/3.9.1/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py", line 72, in multiprocess_1d
    return column, describe_1d(config, series, summarizer, typeset)
  File "/vemv/lib/python3.9/site-packages/multimethod/__init__.py", line 303, in __call__
    return func(*args, **kwargs)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py", line 50, in pandas_describe_1d
    return summarizer.summarize(config, series, dtype=vtype)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/summarizer.py", line 37, in summarize
    _, _, summary = self.handle(str(dtype), config, series, {"type": str(dtype)})
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py", line 62, in handle
    return op(*args)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py", line 21, in func2
    return f(*res)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py", line 21, in func2
    return f(*res)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py", line 21, in func2
    return f(*res)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py", line 17, in func2
    res = g(*x)
  File "/vemv/lib/python3.9/site-packages/multimethod/__init__.py", line 303, in __call__
    return func(*args, **kwargs)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/summary_algorithms.py", line 65, in inner
    return fn(config, series, summary)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/summary_algorithms.py", line 82, in inner
    return fn(config, series, summary)
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/describe_categorical_pandas.py", line 205, in pandas_describe_categorical_1d
    summary.update(length_summary_vc(value_counts))
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/describe_categorical_pandas.py", line 162, in length_summary_vc
    "median_length": weighted_median(
  File "/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/utils_pandas.py", line 13, in weighted_median
    w_median = (data[weights == np.max(weights)])[0]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
```

If I try changing the `minimal` from `False` to `True`, the script is now passing.

**Version information:**

#### Failing environment

Python version: Python 3.9.1
Pip version: pip 21.3.1
Pandas and pandas-profiling versions: 1.4.0 | 3.1.0
Full pip list:
```
Package               Version
--------------------- ---------
attrs                 21.4.0
certifi               2021.10.8
charset-normalizer    2.0.10
cycler                0.11.0
fonttools             4.28.5
htmlmin               0.1.12
idna                  3.3
ImageHash             4.2.1
Jinja2                3.0.3
joblib                1.0.1
kiwisolver            1.3.2
MarkupSafe            2.0.1
matplotlib            3.5.1
missingno             0.5.0
multimethod           1.6
networkx              2.6.3
numpy                 1.22.1
packaging             21.3
pandas                1.4.0
pandas-profiling      3.1.0
phik                  0.12.0
Pillow                9.0.0
pip                   21.3.1
pydantic              1.9.0
pyparsing             3.0.7
python-dateutil       2.8.2
pytz                  2021.3
PyWavelets            1.2.0
PyYAML                6.0
requests              2.27.1
scipy                 1.7.3
seaborn               0.11.2
setuptools            60.0.5
six                   1.16.0
tangled-up-in-unicode 0.1.0
tqdm                  4.62.3
typing_extensions     4.0.1
urllib3               1.26.8
visions               0.7.4
wheel                 0.37.1
```

#### Working environment

Python version: Python 3.9.1
Pip version: pip 21.3.1
Pandas and pandas-profiling versions: 1.3.5 | 3.1.0
Full pip list:
```
Package               Version
--------------------- ---------
attrs                 21.4.0
certifi               2021.10.8
charset-normalizer    2.0.10
cycler                0.11.0
fonttools             4.28.5
htmlmin               0.1.12
idna                  3.3
ImageHash             4.2.1
Jinja2                3.0.3
joblib                1.0.1
kiwisolver            1.3.2
MarkupSafe            2.0.1
matplotlib            3.5.1
missingno             0.5.0
multimethod           1.6
networkx              2.6.3
numpy                 1.22.1
packaging             21.3
pandas                1.3.5
pandas-profiling      3.1.0
phik                  0.12.0
Pillow                9.0.0
pip                   21.3.1
pydantic              1.9.0
pyparsing             3.0.7
python-dateutil       2.8.2
pytz                  2021.3
PyWavelets            1.2.0
PyYAML                6.0
requests              2.27.1
scipy                 1.7.3
seaborn               0.11.2
setuptools            60.0.5
six                   1.16.0
tangled-up-in-unicode 0.1.0
tqdm                  4.62.3
typing_extensions     4.0.1
urllib3               1.26.8
visions               0.7.4
wheel                 0.37.1
```

Let me know if I can provide more details and thank you for your good work!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/pandas_profiling/model/pandas/utils_pandas.py`
Content:
```
1 import numpy as np
2 
3 
4 def weighted_median(data: np.ndarray, weights: np.ndarray) -> int:
5     """
6     Args:
7       data (list or numpy.array): data
8       weights (list or numpy.array): weights
9     """
10     s_data, s_weights = map(np.array, zip(*sorted(zip(data, weights))))
11     midpoint = 0.5 * sum(s_weights)
12     if any(weights > midpoint):
13         w_median = (data[weights == np.max(weights)])[0]
14     else:
15         cs_weights = np.cumsum(s_weights)
16         idx = np.where(cs_weights <= midpoint)[0][-1]
17         if cs_weights[idx] == midpoint:
18             w_median = np.mean(s_data[idx : idx + 2])
19         else:
20             w_median = s_data[idx + 1]
21     return w_median
22
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/pandas_profiling/model/pandas/utils_pandas.py b/src/pandas_profiling/model/pandas/utils_pandas.py
--- a/src/pandas_profiling/model/pandas/utils_pandas.py
+++ b/src/pandas_profiling/model/pandas/utils_pandas.py
@@ -7,10 +7,16 @@
       data (list or numpy.array): data
       weights (list or numpy.array): weights
     """
-    s_data, s_weights = map(np.array, zip(*sorted(zip(data, weights))))
-    midpoint = 0.5 * sum(s_weights)
-    if any(weights > midpoint):
-        w_median = (data[weights == np.max(weights)])[0]
+    if not isinstance(data, np.ndarray):
+        data = np.array(data)
+    if not isinstance(weights, np.ndarray):
+        weights = np.array(weights)
+
+    s_data, s_weights = map(np.sort, [data, weights])
+    midpoint = 0.5 * np.sum(s_weights)
+
+    if s_weights[-1] > midpoint:
+        w_median = data[weights == np.max(weights)][0]
     else:
         cs_weights = np.cumsum(s_weights)
         idx = np.where(cs_weights <= midpoint)[0][-1]

{"golden_diff": "diff --git a/src/pandas_profiling/model/pandas/utils_pandas.py b/src/pandas_profiling/model/pandas/utils_pandas.py\n--- a/src/pandas_profiling/model/pandas/utils_pandas.py\n+++ b/src/pandas_profiling/model/pandas/utils_pandas.py\n@@ -7,10 +7,16 @@\n       data (list or numpy.array): data\n       weights (list or numpy.array): weights\n     \"\"\"\n-    s_data, s_weights = map(np.array, zip(*sorted(zip(data, weights))))\n-    midpoint = 0.5 * sum(s_weights)\n-    if any(weights > midpoint):\n-        w_median = (data[weights == np.max(weights)])[0]\n+    if not isinstance(data, np.ndarray):\n+        data = np.array(data)\n+    if not isinstance(weights, np.ndarray):\n+        weights = np.array(weights)\n+\n+    s_data, s_weights = map(np.sort, [data, weights])\n+    midpoint = 0.5 * np.sum(s_weights)\n+\n+    if s_weights[-1] > midpoint:\n+        w_median = data[weights == np.max(weights)][0]\n     else:\n         cs_weights = np.cumsum(s_weights)\n         idx = np.where(cs_weights <= midpoint)[0][-1]\n", "issue": "Potential incompatiblity with Pandas 1.4.0\n**Describe the bug**\r\n\r\nPandas version 1.4.0 was release few days ago and some tests start failing. I was able to reproduce with a minimum example which is failing with Pandas 1.4.0 and working with Pandas 1.3.5.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nimport pandas as pd\r\nimport pandas_profiling\r\n\r\ndata = {\"col1\": [1, 2], \"col2\": [3, 4]}\r\ndataframe = pd.DataFrame(data=data)\r\n\r\nprofile = pandas_profiling.ProfileReport(dataframe, minimal=False)\r\nprofile.to_html()\r\n```\r\n\r\nWhen running with Pandas 1.4.0, I get the following traceback:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/tmp/bug.py\", line 8, in <module>\r\n    profile.to_html()\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py\", line 368, in to_html\r\n    return self.html\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py\", line 185, in html\r\n    self._html = self._render_html()\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py\", line 287, in _render_html\r\n    report = self.report\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py\", line 179, in report\r\n    self._report = get_report_structure(self.config, self.description_set)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/profile_report.py\", line 161, in description_set\r\n    self._description_set = describe_df(\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/describe.py\", line 71, in describe\r\n    series_description = get_series_descriptions(\r\n  File \"/vemv/lib/python3.9/site-packages/multimethod/__init__.py\", line 303, in __call__\r\n    return func(*args, **kwargs)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py\", line 92, in pandas_get_series_descriptions\r\n    for i, (column, description) in enumerate(\r\n  File \"/home/lothiraldan/.pyenv/versions/3.9.1/lib/python3.9/multiprocessing/pool.py\", line 870, in next\r\n    raise value\r\n  File \"/home/lothiraldan/.pyenv/versions/3.9.1/lib/python3.9/multiprocessing/pool.py\", line 125, in worker\r\n    result = (True, func(*args, **kwds))\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py\", line 72, in multiprocess_1d\r\n    return column, describe_1d(config, series, summarizer, typeset)\r\n  File \"/vemv/lib/python3.9/site-packages/multimethod/__init__.py\", line 303, in __call__\r\n    return func(*args, **kwargs)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/summary_pandas.py\", line 50, in pandas_describe_1d\r\n    return summarizer.summarize(config, series, dtype=vtype)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/summarizer.py\", line 37, in summarize\r\n    _, _, summary = self.handle(str(dtype), config, series, {\"type\": str(dtype)})\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py\", line 62, in handle\r\n    return op(*args)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py\", line 21, in func2\r\n    return f(*res)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py\", line 21, in func2\r\n    return f(*res)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py\", line 21, in func2\r\n    return f(*res)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/handler.py\", line 17, in func2\r\n    res = g(*x)\r\n  File \"/vemv/lib/python3.9/site-packages/multimethod/__init__.py\", line 303, in __call__\r\n    return func(*args, **kwargs)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/summary_algorithms.py\", line 65, in inner\r\n    return fn(config, series, summary)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/summary_algorithms.py\", line 82, in inner\r\n    return fn(config, series, summary)\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/describe_categorical_pandas.py\", line 205, in pandas_describe_categorical_1d\r\n    summary.update(length_summary_vc(value_counts))\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/describe_categorical_pandas.py\", line 162, in length_summary_vc\r\n    \"median_length\": weighted_median(\r\n  File \"/vemv/lib/python3.9/site-packages/pandas_profiling/model/pandas/utils_pandas.py\", line 13, in weighted_median\r\n    w_median = (data[weights == np.max(weights)])[0]\r\nIndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices\r\n```\r\n\r\nIf I try changing the `minimal` from `False` to `True`, the script is now passing.\r\n\r\n**Version information:**\r\n\r\n#### Failing environment\r\n\r\nPython version: Python 3.9.1\r\nPip version: pip 21.3.1\r\nPandas and pandas-profiling versions: 1.4.0 | 3.1.0\r\nFull pip list:\r\n```\r\nPackage               Version\r\n--------------------- ---------\r\nattrs                 21.4.0\r\ncertifi               2021.10.8\r\ncharset-normalizer    2.0.10\r\ncycler                0.11.0\r\nfonttools             4.28.5\r\nhtmlmin               0.1.12\r\nidna                  3.3\r\nImageHash             4.2.1\r\nJinja2                3.0.3\r\njoblib                1.0.1\r\nkiwisolver            1.3.2\r\nMarkupSafe            2.0.1\r\nmatplotlib            3.5.1\r\nmissingno             0.5.0\r\nmultimethod           1.6\r\nnetworkx              2.6.3\r\nnumpy                 1.22.1\r\npackaging             21.3\r\npandas                1.4.0\r\npandas-profiling      3.1.0\r\nphik                  0.12.0\r\nPillow                9.0.0\r\npip                   21.3.1\r\npydantic              1.9.0\r\npyparsing             3.0.7\r\npython-dateutil       2.8.2\r\npytz                  2021.3\r\nPyWavelets            1.2.0\r\nPyYAML                6.0\r\nrequests              2.27.1\r\nscipy                 1.7.3\r\nseaborn               0.11.2\r\nsetuptools            60.0.5\r\nsix                   1.16.0\r\ntangled-up-in-unicode 0.1.0\r\ntqdm                  4.62.3\r\ntyping_extensions     4.0.1\r\nurllib3               1.26.8\r\nvisions               0.7.4\r\nwheel                 0.37.1\r\n```\r\n\r\n#### Working environment\r\n\r\nPython version: Python 3.9.1\r\nPip version: pip 21.3.1\r\nPandas and pandas-profiling versions: 1.3.5 | 3.1.0\r\nFull pip list:\r\n```\r\nPackage               Version\r\n--------------------- ---------\r\nattrs                 21.4.0\r\ncertifi               2021.10.8\r\ncharset-normalizer    2.0.10\r\ncycler                0.11.0\r\nfonttools             4.28.5\r\nhtmlmin               0.1.12\r\nidna                  3.3\r\nImageHash             4.2.1\r\nJinja2                3.0.3\r\njoblib                1.0.1\r\nkiwisolver            1.3.2\r\nMarkupSafe            2.0.1\r\nmatplotlib            3.5.1\r\nmissingno             0.5.0\r\nmultimethod           1.6\r\nnetworkx              2.6.3\r\nnumpy                 1.22.1\r\npackaging             21.3\r\npandas                1.3.5\r\npandas-profiling      3.1.0\r\nphik                  0.12.0\r\nPillow                9.0.0\r\npip                   21.3.1\r\npydantic              1.9.0\r\npyparsing             3.0.7\r\npython-dateutil       2.8.2\r\npytz                  2021.3\r\nPyWavelets            1.2.0\r\nPyYAML                6.0\r\nrequests              2.27.1\r\nscipy                 1.7.3\r\nseaborn               0.11.2\r\nsetuptools            60.0.5\r\nsix                   1.16.0\r\ntangled-up-in-unicode 0.1.0\r\ntqdm                  4.62.3\r\ntyping_extensions     4.0.1\r\nurllib3               1.26.8\r\nvisions               0.7.4\r\nwheel                 0.37.1\r\n```\r\n\r\nLet me know if I can provide more details and thank you for your good work!\n", "before_files": [{"content": "import numpy as np\n\n\ndef weighted_median(data: np.ndarray, weights: np.ndarray) -> int:\n    \"\"\"\n    Args:\n      data (list or numpy.array): data\n      weights (list or numpy.array): weights\n    \"\"\"\n    s_data, s_weights = map(np.array, zip(*sorted(zip(data, weights))))\n    midpoint = 0.5 * sum(s_weights)\n    if any(weights > midpoint):\n        w_median = (data[weights == np.max(weights)])[0]\n    else:\n        cs_weights = np.cumsum(s_weights)\n        idx = np.where(cs_weights <= midpoint)[0][-1]\n        if cs_weights[idx] == midpoint:\n            w_median = np.mean(s_data[idx : idx + 2])\n        else:\n            w_median = s_data[idx + 1]\n    return w_median\n", "path": "src/pandas_profiling/model/pandas/utils_pandas.py"}], "after_files": [{"content": "import numpy as np\n\n\ndef weighted_median(data: np.ndarray, weights: np.ndarray) -> int:\n    \"\"\"\n    Args:\n      data (list or numpy.array): data\n      weights (list or numpy.array): weights\n    \"\"\"\n    if not isinstance(data, np.ndarray):\n        data = np.array(data)\n    if not isinstance(weights, np.ndarray):\n        weights = np.array(weights)\n\n    s_data, s_weights = map(np.sort, [data, weights])\n    midpoint = 0.5 * np.sum(s_weights)\n\n    if s_weights[-1] > midpoint:\n        w_median = data[weights == np.max(weights)][0]\n    else:\n        cs_weights = np.cumsum(s_weights)\n        idx = np.where(cs_weights <= midpoint)[0][-1]\n        if cs_weights[idx] == midpoint:\n            w_median = np.mean(s_data[idx : idx + 2])\n        else:\n            w_median = s_data[idx + 1]\n    return w_median\n", "path": "src/pandas_profiling/model/pandas/utils_pandas.py"}]}