Skip to content

Commit

Permalink
instantiate Dataset with explicit kdims
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Jul 19, 2024
1 parent 0c4ee82 commit adbddf7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ def _process_data(

if gridded_data:
not_found = [g for g in groupby if g not in data.coords]
not_found, _, _ = process_derived_datetime_xarray(data, not_found)
post_not_found, _, _ = process_derived_datetime_xarray(data, not_found)
data_vars = list(data.data_vars) if isinstance(data, xr.Dataset) else [data.name]
indexes = list(data.coords.indexes)
# Handle undeclared indexes
Expand All @@ -1188,7 +1188,8 @@ def _process_data(
if coord not in groupby + by:
groupby.append(data_dim)
self.variables = list(data.coords) + data_vars
if groupby and not_found:
self.variables.extend([item for item in not_found if item not in post_not_found])
if groupby and post_not_found:
raise ValueError(
f'The supplied groupby dimension(s) {not_found} '
'could not be found, expected one or '
Expand Down Expand Up @@ -1257,13 +1258,16 @@ def _process_data(
not_found = [
g for g in groupby + by_cols if g not in list(self.data.columns) + indexes
]
not_found, self.data = process_derived_datetime_pandas(self.data, not_found, indexes)
if groupby and not_found:
post_not_found, self.data = process_derived_datetime_pandas(
self.data, not_found, indexes
)
if groupby and post_not_found:
raise ValueError(
f'The supplied groupby dimension(s) {not_found} '
'could not be found, expected one or '
f'more of: {list(self.data.columns)}'
)
self.variables.extend([item for item in not_found if item not in post_not_found])

if transforms:
self.data = Dataset(self.data, indexes).transform(**transforms).data
Expand Down Expand Up @@ -1560,7 +1564,7 @@ def __call__(self, kind, x, y):
name = data.name or self.label or self.value_label
dataset = Dataset(data, self.indexes, name)
else:
dataset = Dataset(data)
dataset = Dataset(data, self.variables)
dataset = dataset.redim(**self._redim)

if groups:
Expand Down Expand Up @@ -2078,7 +2082,8 @@ def _process_chart_args(self, data, x, y, single_y=False, categories=None):
dimensions.extend(col if isinstance(col, list) else [col])

not_found = [dim for dim in dimensions if dim not in self.variables]
_, data = process_derived_datetime_pandas(data, not_found, self.indexes)
post_not_found, data = process_derived_datetime_pandas(data, not_found, self.indexes)
self.variables.extend(set(post_not_found) - set(not_found))

return data, x, y

Expand Down Expand Up @@ -2609,7 +2614,8 @@ def _process_gridded_args(self, data, x, y, z):
dimensions.extend(dimension if isinstance(dimension, list) else [dimension])

not_found = [dim for dim in dimensions if dim not in self.variables]
_, data = process_derived_datetime_pandas(data, not_found, self.indexes)
post_not_found, data = process_derived_datetime_pandas(data, not_found, self.indexes)
self.variables.extend([item for item in not_found if item not in post_not_found])

return data, x, y, z

Expand Down

0 comments on commit adbddf7

Please sign in to comment.