Skip to content

Commit

Permalink
write all NaN and NaT Dataframe created values as null
Browse files Browse the repository at this point in the history
  • Loading branch information
kbuma committed Feb 29, 2024
1 parent 767a024 commit 33806c1
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

Check warning on line 7 in src/maggma/stores/open_data.py

View check run for this annotation

Codecov / codecov/patch

src/maggma/stores/open_data.py#L7

Added line #L7 was not covered by tests
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})

Check warning on line 629 in src/maggma/stores/open_data.py

View check run for this annotation

Codecov / codecov/patch

src/maggma/stores/open_data.py#L629

Added line #L629 was not covered by tests

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 33806c1

Please sign in to comment.