Skip to content

Commit 028bcdf

Browse files
duetosymmetrycrazyeng
authored andcommitted
Encode the pandas NaT (not-a-time) singleton type (fixes #43)
The pandas package has a singleton pandas.NaT of type pandas.api.typing.NaTType to represent an entry in a datetime field which is missing/broken/null. A reasonable encoding is pandas.NaT -> Indeterminate
1 parent 965da78 commit 028bcdf

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎wolframclient/serializers/encoders/pandas.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,8 @@ def encode_panda_series(serializer, o):
200200
if is_legacy_mode():
201201
return legacy_encode_series(serializer, o)
202202
return pyarrow_serialize(serializer, o.to_frame())
203+
204+
205+
@encoder.dispatch(pandas.NaT)
206+
def encode_pandas_not_a_time(serializer, o):
207+
return serializer.serialize_symbol(b"Indeterminate")

‎wolframclient/utils/api.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
SparseArray="pandas.SparseArray",
154154
RangeIndex="pandas.RangeIndex",
155155
ArrowDtype="pandas.ArrowDtype",
156+
NaT="pandas.api.typing.NaTType",
156157
)
157158

158159
pyarrow = API(

0 commit comments

Comments
 (0)