GabrielHenriqueCA opened a new pull request, #60652: URL: https://github.com/apache/spark/pull/60652
### What changes were proposed in this pull request? Port the private pandas helper `infer_dtype_from_object` to `pyspark.pandas.utils`, using only public pandas and NumPy APIs, and make `DataFrame.select_dtypes` use it instead of importing it from `pandas.core.dtypes.common`. ### Why are the changes needed? pandas 3.1.0 removed `pandas.core.dtypes.common.infer_dtype_from_object`, which `python/pyspark/pandas/frame.py` imports at module level. As a result, `import pyspark.pandas` raises `ImportError` with pandas 3.1. This is the remaining half of the pandas 3.1 import failure; the `DateOffset` half was fixed by SPARK-61360. Sub-task of SPARK-55139. ### Does this PR introduce _any_ user-facing change? Yes. With pandas 3.1, `import pyspark.pandas` now works instead of raising `ImportError`. Behavior with pandas 2.x and 3.0 is unchanged. ### How was this patch tested? Added `test_infer_dtype_from_object` and `test_select_dtypes` in `python/pyspark/pandas/tests/test_utils.py`. The port returns the same result as the pandas helper for every input checked on pandas 2.2.3 and 3.0.6. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) The implementation was co-authored by Gabriel Henrique and Claude Code. Gabriel Henrique led the investigation, wrote part of the code, and reviewed and validated every change before submission. Claude Code helped write parts of the implementation and tests, and assisted with review and validation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
