Repository navigation
Display an informative DataFrame index in table plots - #1783
Open
fatimaLaraibBonk wants to merge 1 commit into
Open
fatimaLaraibBonk wants to merge 1 commit into
fatimaLaraibBonk wants to merge 1 commit into
Conversation
df.hvplot.table() only displayed the index for a DatetimeIndex or a MultiIndex. Any other index, such as a named index or an index of strings, was dropped from the table, because Bokeh does not render the DataFrame index. Display the index whenever it carries information, and keep hiding an unnamed integer index, which only holds row numbers. Fixes holoviz#1734
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1734
df.hvplot.table()drops the DataFrame index unless it is aDatetimeIndexor aMultiIndex. A string index, such as names, IDs or categories, disappears from the table, so the rows can no longer be identified. This happens because Bokeh doesn't render the index, and hvPlot only resets it into a column for those two index types.Reproduction
Before: the table only has
salesandprofit, and thecitycolumn is missing.After: the table has
city,salesandprofit.What decides whether the index is shown
The index is reset into a column when it carries information: a MultiIndex, a named index, or any non-integer index (strings, categories, datetimes). An unnamed integer index is still hidden, because it only holds row numbers and the table already shows those. Tables of a plain DataFrame or a filtered DataFrame therefore look the same as before.
Tests
New cases in
hvplot/tests/kinds/test_table.pycover named and unnamed string indexes, a named integer index and a categorical index (all fail onmain), and check that aRangeIndexand an unnamed integer index stay hidden. The full test suite passes (2181 passed), with the same xpassed tests asmain.