Skip to content

ENH: Utility to return "feasible" dtype for infer_dtype output. #61256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mroeschke opened this issue Apr 8, 2025 · 1 comment
Open

ENH: Utility to return "feasible" dtype for infer_dtype output. #61256

mroeschke opened this issue Apr 8, 2025 · 1 comment
Labels
Enhancement Needs Discussion Requires discussion from core team before further action

Comments

@mroeschke
Copy link
Member

pandas.api.types.infer_dtype returns a string label of the inferred type of data. (While these should probably be an enum), these string labels do not map cleanly to what supported pandas data type represents that data e.g "mixed" would probably map to "object"

It would be nice to

  1. Add a parameter as_pandas_type: bool = False that would return an enum representing the supported pandas type (e.g. "mixed" and "unknown-array", maps to "PandasType.OBJECT")
  2. Add a separate function to do this
@arthurlw
Copy link
Contributor

arthurlw commented Apr 9, 2025

If we add the as_pandas_type parameter in infer_dtype, is a separate function still necessary?

I think having a separate function makes the mapping logic reusable outside of infer_dtype (like for testing or downstream libraries), but I’m curious if others see it as necessary if we already have the param and the enum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

2 participants