BUG: allow kwargs in Styler apply_index and map_index#1725
Open
eosti wants to merge 1 commit intopandas-dev:mainfrom
Open
BUG: allow kwargs in Styler apply_index and map_index#1725eosti wants to merge 1 commit intopandas-dev:mainfrom
eosti wants to merge 1 commit intopandas-dev:mainfrom
Conversation
| self, series: Series, /, *args: Any, **kwargs: Any | ||
| ) -> list[Any] | Series: ... | ||
|
|
||
| class _SeriesStrFunc(Protocol): |
Member
There was a problem hiding this comment.
I tried on my end and this protocol thing works but is a bit of overkill for what you are trying to do here. Turns out since args and kwargs here are just Any, you can drop it in exchange for:
Callable[Concatenate[Series, ...]], list[str] | np_ndarray_str | Series[str]]
This will make it a lot cleaner and simpler to understand.
Member
loicdiridollou
left a comment
There was a problem hiding this comment.
There is an opportunity to simplify here, the tests though are looking good!
| check(assert_type(DF.style.apply_index(f1), Styler), Styler) | ||
|
|
||
| # GH 1723 | ||
| def highlight_odd(index: pd.Series, /, color: str) -> list[str]: |
Member
There was a problem hiding this comment.
No need for the /, it should work without it since it is hardly a usecase you see in production code.
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.
Adds ability to pass a function with
**kwargsto Stylerapply_indexandmap_index. Theapplyandmapfunctions already supported this.apply_*andmapfunctions do not accept**kwargs#1723assert_type()to assert the type of any return value)AGENTS.md.