eicu-code
eicu-code copied to clipboard
Replace pdvega with Holoviews for Compatibility with Pandas Version >= 2.0.0
Hi there!
TL;DR
I noticed that pdvega/vgplot no longer compatible with pandas and replaced it with the corresponding holoviews pieces since this looks to me like the most reasonable alternative to pdvega right now. (holoviews allows interactiv plotting and multiple backends like matplotlib or plotly).
You might need to take a look at the notebook outputs with nbviewer, github doesn't render the holoviews output in preview mode: https://github.com/DanielBrkr/eicu-code/tree/replace-pdvega/notebooks
Details
Here's an example of the portions that cause errors:
df[['data completion']].vgplot.hist(bins=10,
var_name='Number of hospitals',
value_name='Percent of patients with data')
Traceback:
AttributeError: module 'pandas.core' has no attribute 'index'
. . .
File ~\AppData\Local\pypoetry\Cache\virtualenvs\eicu-code-BSlVd4Lx-py3.11\Lib\site-packages\vega3\utils.py:40, in sanitize_dataframe(df)
36 import numpy as np
38 df = df.copy()
---> 40 if isinstance(df.index, pd.core.index.MultiIndex):
41 raise ValueError('Hierarchical indices not supported')
42 if isinstance(df.columns, pd.core.index.MultiIndex):
Deprecation in https://github.com/pandas-dev/pandas/pull/30193 (2019)
and removal of pandas.core.index in Version 2.0.0 (April 2023) https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html#removal-of-prior-version-deprecations-changes
Removed deprecated module
pandas.core.index
(GH 30193)
pdvega is no longer developed since June 2020 other than that so i think it's a good idea to replace it anyway.
Feel free to merge it if it's any help and let me know if I need to change anything !