-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Minimal example demonstrating the problem:
import pandas as pd
from wolframclient.serializers import export
# this has type pandas.Timestamp
good_time = pd.to_datetime('2026-02-25T17:30:16+00:00')
# this rather has type pandas.api.typing.NaTType
bad_time = pd.NaT
export(good_time)
# returns b'DateObject[{2026, 2, 25, 17, 30, 16.}, "Instant", "Gregorian", "UTC"]'
export(bad_time)
# raises the below ValueErrorHere is the resulting exception:
----> 1 export(bad_time)
File ~/miniconda3/envs/test_wolframclient/lib/python3.14/site-packages/wolframclient/serializers/__init__.py:68, in export(data, stream, target_format, **options)
63 if not target_format in available_formats:
64 raise ValueError(
65 "Invalid export format %s. Choices are: %s"
66 % (target_format, ", ".join(available_formats.keys()))
67 )
---> 68 return available_formats[target_format](**options).export(data, stream=stream)
File ~/miniconda3/envs/test_wolframclient/lib/python3.14/site-packages/wolframclient/serializers/base.py:35, in FormatSerializer.export(self, data, stream)
32 stream.write(token)
33 return stream
---> 35 return concatenate_bytes(self.generate_bytes(data))
File ~/miniconda3/envs/test_wolframclient/lib/python3.14/site-packages/wolframclient/serializers/wl.py:17, in yield_with_separators(iterable, first, last, separator)
15 if i:
16 yield separator
---> 17 for sub in arg:
18 yield sub
19 yield last
File ~/miniconda3/envs/test_wolframclient/lib/python3.14/site-packages/wolframclient/serializers/wl.py:17, in yield_with_separators(iterable, first, last, separator)
15 if i:
16 yield separator
---> 17 for sub in arg:
18 yield sub
19 yield last
File ~/miniconda3/envs/test_wolframclient/lib/python3.14/site-packages/wolframclient/serializers/wl.py:58, in WLSerializer.serialize_int(self, number)
57 def serialize_int(self, number):
---> 58 yield b"%i" % number
ValueError: cannot convert float NaN to integer
This is different from how the exporter handles NaN (not a number):
import numpy as np
export(np.nan)
# returns b'Indeterminate'Expected behavior: The serializer should detect NaT and treat it like NaN, returning Indeterminate.
EDITED to add: This affects both target_format='wl' and target_format='wxf'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels