Skip to content

fix: count rows per cell when heatmap C is not set - #1743

Open
ghostiee-11 wants to merge 1 commit into
holoviz:mainfrom
ghostiee-11:fix/heatmap-count-when-C-unset
Open

fix: count rows per cell when heatmap C is not set#1743
ghostiee-11 wants to merge 1 commit into
holoviz:mainfrom
ghostiee-11:fix/heatmap-count-when-C-unset

Conversation

@ghostiee-11

Copy link
Copy Markdown

df.hvplot.heatmap(x, y) raised ValueError: NoneType type could not be interpreted as Dimension instead of plotting, even though C is documented as optional with "a simple count" as the default. This makes that documented count actually work.

Fixes #1610. Fixes #908, which is the same crash reached through a lowercase c= typo.

heatmap documents C as optional, with a simple count used when it is
omitted, but omitting it raised "NoneType type could not be interpreted
as Dimension". core.py always forwards C=C, so C=None was present in
kwds and self.kwds.get('C', fallback) never reached its fallback.

Resolve C with a plain get and count the rows in each (x, y) cell when
it is None, so the documented behaviour works. This also makes the two
entry points agree: df.hvplot(kind='heatmap') previously plotted the
first non-x/y column, picked arbitrarily, and now counts as well.

The grouping runs after _process_chart_args so that derived dimensions
such as 'time.hour' are real columns by then, and passes observed=True
to keep categorical axes from expanding into the full product of their
categories.

hover_cols and reduce_function cannot apply to a cell holding a count,
so they are now reported as ignored rather than silently dropped, and
reduce_function is skipped in that case because np.size would otherwise
flatten every count to 1.

Fixes holoviz#1610
Fixes holoviz#908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when not setting heatmap's C option Provide helpful error message for not providing C to heatmap

1 participant