Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Jan 14, 2025

Describe your changes

Separates Pandas Styler handling in the frontend into a dedicated utils module. This also extracts the logic around styled cells & headers from the getCell Quiver method to separate raw data handling and handling of styling information. Also changes getCell to only return actual data cells and not column header names as well.

The changes in this PR do not change any visual or behavioral changes.

Testing Plan

  • Added and updated unit tests.
  • Added additional e2e screenshot test for advanced pandas styler usage with st.table

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@lukasmasuch lukasmasuch changed the title Refactor Pandas styler handling in frontend [WIP] Refactor Pandas styler handling in frontend Jan 14, 2025
@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR impact:internal PR changes only affect internal code change:refactor PR contains code refactoring without behavior change labels Jan 14, 2025
@lukasmasuch lukasmasuch changed the title [WIP] Refactor Pandas styler handling in frontend Refactor Pandas styler handling in frontend Jan 14, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review January 14, 2025 18:08
}

/**
* Generate a table index or data cell from a Quiver object.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between a table index and a data cell? Why can the function return both? Is there a way to provide an example in the JSDoc here of how this looks like? When not being deep into this Arrow-stuff, I find it a little bit tough to understand what exactly is returned here.
Also, perhaps it makes sense to rename the function to generateTableCellOrIndex.

Or do you mean either an "index cell" or a "data cell"? But not sure whether this even makes sense conceptually (like how would a cell be an index 😅)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you mean either an "index cell" or a "data cell"?

Yep, I updated the comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the index cell vs data cell distinction is not so important for arrowtable, the only difference is that it is using a greyed-out color

}

/** Return a single cell in the table. */
/** Return a single index or data cell from the DataFrame.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, what is an index cell?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index cell is a cell from an index columm. An index column refers to the index from Pandas. Therefore, it only exists if the data was processed through Pandas. Unfortunately, it needs a bit of special treatment in our data handling :(

@lukasmasuch lukasmasuch merged commit 8155946 into develop Jan 15, 2025
33 checks passed
@lukasmasuch lukasmasuch deleted the refactor/pandas-styler-handling branch January 15, 2025 12:52
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
## Describe your changes

Separates Pandas Styler handling in the frontend into a dedicated utils
module. This also extracts the logic around styled cells & headers from
the `getCell` Quiver method to separate raw data handling and handling
of styling information. Also changes `getCell` to only return actual
data cells and not column header names as well.

The changes in this PR do not change any visual or behavioral changes. 

## Testing Plan

- Added and updated unit tests. 
- Added additional e2e screenshot test for advanced pandas styler usage
with `st.table`

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants