MLServer icon indicating copy to clipboard operation
MLServer copied to clipboard

Fix pandas codec nan conversion for non-numeric columns

Open guillermo-alicea opened this issue 1 month ago • 1 comments

Description

This changes fixes a bug in the PandasCodec to_response_output conversion function which raises the following error when null values are attempted to be checked as nan values using numpy.isnan(x). This can occur in cases such as a string series with nullable entries.

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Changes Made

  • Update PandasCodec ResponseOutput mapper to skip nan conversion for BYTES column
    • This change mirrors the behavior present in NumpyCodec
  • Update PandasCodec string content type detection to ignore null values in an otherwise string column

Related Issues

  • https://github.com/SeldonIO/MLServer/issues/1873
  • https://github.com/SeldonIO/MLServer/issues/1747#issuecomment-2411056443

Screenshots (if applicable)

N/A

Checklist

  • [x] Code follows the project's style guidelines
  • [x] All tests related to the changes pass successfully
  • [x] Documentation is updated (if necessary)
  • [ ] Code is reviewed by at least one other team member
  • [ ] Any breaking changes are communicated and documented

Additional Notes

N/A

guillermo-alicea avatar Nov 22 '25 04:11 guillermo-alicea

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 22 '25 04:11 CLAassistant