Attempt to convert pandas.NaT / pandas.NA
(obj)
| 269 | |
| 270 | @staticmethod |
| 271 | def encode_as_pandas(obj): |
| 272 | """Attempt to convert pandas.NaT / pandas.NA""" |
| 273 | pandas = get_module("pandas", should_load=False) |
| 274 | if not pandas: |
| 275 | raise NotEncodable |
| 276 | |
| 277 | if obj is pandas.NaT: |
| 278 | return None |
| 279 | |
| 280 | # pandas.NA was introduced in pandas 1.0 |
| 281 | if hasattr(pandas, "NA") and obj is pandas.NA: |
| 282 | return None |
| 283 | |
| 284 | raise NotEncodable |
| 285 | |
| 286 | @staticmethod |
| 287 | def encode_as_numpy(obj): |