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

Comment From: arthurlw

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.

Comment From: jbrockmendel

While these should probably be an enum

+1

I guess this is still used in the wild, but I've been trying to wean off internal uses for a while because there's almost always a better alternative.