Uploaded image for project: 'pymongoarrow'
  1. pymongoarrow
  2. ARROW-136

Add a workaround in write() for Pandas NA datetime objects

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 1.6
    • Affects Version/s: None
    • Component/s: None
    • None

      In ARROW-134, we added a workaround for Pandas NaT objects in the pandas test. We should encode NaT datetimes as BSON null in the write() function.

      Encoding a pandas.NaT object results in an error:

      bindings/python/test/test_pandas.py:114: in round_trip
          res = write(self.coll, data)
      bindings/python/pymongoarrow/api.py:394: in write
          enc_tab = RawBSONDocument(encode(next(tabular_gen), codec_options=codec_options))
      ../../work/pycharm/mongo-arrow/lib/python3.10/site-packages/bson/__init__.py:1021: in encode
          return _dict_to_bson(document, check_keys, codec_options)
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      
      >   ???
      E   ValueError: NaTType does not support utcoffset
      
      pandas/_libs/tslibs/nattype.pyx:67: ValueError
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            steve.silvester@mongodb.com Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: