Skip to content

Commit

Permalink
Revert PR 5354 validating DataFrame column type (#5457)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Sep 30, 2022
1 parent a324806 commit e2f55d4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions holoviews/core/data/pandas.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from functools import lru_cache
from warnings import warn

import numpy as np
import pandas as pd

Expand All @@ -10,6 +13,12 @@
from .util import finite_range


@lru_cache(maxsize=None)
def deprecation_warning(msg):
"To only run the warning once"
warn(msg, DeprecationWarning, stacklevel=2)


class PandasInterface(Interface):

types = (pd.DataFrame if pd else None,)
Expand Down Expand Up @@ -55,9 +64,12 @@ def init(cls, eltype, data, kdims, vdims):
elif kdims == [] and vdims is None:
vdims = list(data.columns[:nvdim if nvdim else None])

if any(isinstance(d, (np.int64, int)) for d in kdims+vdims):
raise DataError("pandas DataFrame column names used as dimensions "
"must be strings not integers.", cls)
if any(not isinstance(d, str) for d in kdims+vdims):
deprecation_warning(
"Having a non-string as a column name in a DataFrame is deprecated "
"and will not be supported in Holoviews version 1.16."
)

# Handle reset of index if kdims reference index by name
for kd in kdims:
kd = dimension_name(kd)
Expand All @@ -67,6 +79,9 @@ def init(cls, eltype, data, kdims, vdims):
for name in index_names):
data = data.reset_index()
break
if any(isinstance(d, (np.int64, int)) for d in kdims+vdims):
raise DataError("pandas DataFrame column names used as dimensions "
"must be strings not integers.", cls)

if kdims:
kdim = dimension_name(kdims[0])
Expand Down

0 comments on commit e2f55d4

Please sign in to comment.