Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write all NaN and NaT Dataframe created values as null #929

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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