ENH: Adding implementation for issue #51748
- [X] closes #51748 (Replace xxxx with the GitHub issue number)
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [X] Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

* Adding implementation for issue #51748 51748

Hi  @MarcoGorelli, this PR should be good to go now since I have taken care of all 5 tasks. I'm not sure if I should reach out to someone to inspect this PR. I'm not sure we should be expanding the API here; I've put some comments in the linked issue. @rhshadrach I saw the comments. Should I cancel the PR?  In this instance, I would recommend closing to take it off the queue until there is some consensus for this feature. We can reopen if we decide to go forward with it. In the meantime, any feedback in the linked issue on why this is worth supporting would help in pushing the discussion forward. @rhshadrach In the future, should I avoid tackling enhancement requests with the `Needs Triage` tag? It seems like I jumped the gun on this one Yes - that would be my recommendation. And I would also extend that to enhancements that do not have a consensus among core developers as to whether they should be added. The pandas API is very large, and we are cautious about making potentially unnecessary additions.