TST: add tests for nullable astype behavior (NaN/<NA> preservation) #62959
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 small, focused tests covering nullable dtype casting behavior to ensure missing values are preserved or converted as expected during astype operations.
Adds pandas/tests/dtypes/test_nullable_astype.py with:
test_series_astype_nullable_int_preserves_nans: float -> Int64 should convert NaN to .
test_series_astype_from_nullable_int_to_float_roundtrip: Int64 -> float -> Int64 roundtrip preserves missingness.
test_nullable_series_astype_various_dtypes_preserve_missing: parametrized coverage for Int32/Int64/Float32/Float64.
Rationale:
Small, deterministic tests that exercise edge cases around pd.NA and numpy NaN during dtype conversion.
No behavioral changes to core code; this enhances test coverage and guards against regressions.
How to run locally: pytest -q pandas/tests/dtypes/test_nullable_astype.py
Notes:
Uses pandas.testing assertions and pytest parametrization.
No external dependencies or network I/O.