uranusjr commented on PR #23132:
URL: https://github.com/apache/airflow/pull/23132#issuecomment-1148082291
This is probably a better solution
```python
import math
try:
import numpy
except ImportError:
numpy = None # type: ignore
...
elif isinstance(cell, float) and math.isnan(cell): # coerce NaN to NULL
...
elif numpy and isinstance(cell, numpy.datetime64):
...
```
For the `float` case, `math.isnan` is identical to `numpy.isnan` (the numpy
implementation covers more cases for _numpy-specific types_ that we don’t care
about here). And for numpy-specific types, we can simply make the check
optional—if `numpy` fails to import, the instance obviously cannot come from
numpy.
--
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]