Skip to content

Commit

Permalink
Merge pull request #929 from kbuma/bugfix/handle-NaN-NaT
Browse files Browse the repository at this point in the history
write all NaN and NaT Dataframe created values as null
  • Loading branch information
munrojm committed Feb 29, 2024
2 parents 767a024 + 33806c1 commit d83341e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/maggma/stores/open_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Dict, Generator, List, Optional, Tuple, Union

import jsonlines
import numpy as np
import pandas as pd
from boto3 import client as boto_client
from botocore import UNSIGNED
Expand Down Expand Up @@ -625,6 +626,8 @@ def _write_doc_and_update_index(self, items: pd.DataFrame, index: pd.DataFrame)
self.index.update(index)

def _write_doc_to_s3(self, doc: pd.DataFrame, index: pd.DataFrame) -> None:
doc = doc.replace({pd.NaT: None}).replace({"NaT": None}).replace({np.NaN: None})

string_io = StringIO()
with jsonlines.Writer(string_io, dumps=json_util.dumps) as writer:
for _, row in doc.iterrows():
Expand Down

0 comments on commit d83341e

Please sign in to comment.