hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

Incorrect DeprecationWarning: Having a non-string as a column name in a DataFrame

Open 2-5 opened this issue 1 year ago • 4 comments

ALL software version info

python-3.10.4 holoviews-1.15.1 hvplot-0.8.1 panel-0.14.0 pandas-1.5.0 VS Code 1.72.1 Jupyter Extension v2022.9.1202862440 Windows 10

Description of expected behavior and the observed behavior

A DeprecationWarning is raised, but it seems it should not:

DeprecationWarning: Having a non-string as a column name in a DataFrame is deprecated and will not be supported in Holoviews version 1.16.

Complete, minimal, self-contained example code that reproduces the issue

import pandas as pd
import hvplot.pandas

data = [["a", 1], ["b", 2], ["c", 3]]

df = pd.DataFrame(data, columns=["x", "y"])
df.hvplot()

Screenshots or screencasts of the bug in action

2022-10-12_201227

2-5 avatar Oct 12 '22 17:10 2-5

It seems the cause is that holoviews wraps DataFrame columns in Dimension, and the code which throws the warning strictly checks against str, and doesn't handle Dimension columns.

2-5 avatar Oct 12 '22 17:10 2-5

Yes. This should be fixed when this https://github.com/holoviz/holoviews/pull/5470 is merged.

Curious about why you see the warning in your notebook. Do you have any custom settings enabled?

hoxbro avatar Oct 12 '22 18:10 hoxbro

I have this env variable set: PYTHONWARNINGS=default. Due to it I often see deprecation warnings in various projects. Maybe it would be a good idea if at least some holoviz devs would also enable it on their dev machines.

https://docs.python.org/3/library/warnings.html#updating-code-for-new-versions-of-dependencies

2-5 avatar Oct 12 '22 18:10 2-5

Thanks @2-5, for the PYTHONWARNINGS=default trick and for reporting this issue, we have indeed missed the Dimension case in the warning that is emitted, this is going to be fixed in the next release of HoloViews.

maximlt avatar Oct 13 '22 12:10 maximlt