Skip to content

Commit 5374546

Browse files
committed
string Nans
1 parent 41911b9 commit 5374546

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,12 @@ def tsv_to_json_pandas(tsv_string, project_id):
580580

581581
# Handle strings
582582
elif field_type == "string":
583-
df[column] = df[column].apply(lambda x: x if x is not None else "")
583+
# For string fields, always use empty string for missing/None/NaN
584+
df[column] = df[column].apply(lambda x: x if (x is not None and not (isinstance(x, float) and pd.isna(x))) else "")
584585

585586
# Other types: leave as is
586587

587-
# Replace all NaN with None for JSON compatibility
588+
# For non-string fields, ensure NaN is replaced with None
588589
import math
589590
def clean_nans(obj):
590591
if isinstance(obj, float) and math.isnan(obj):

0 commit comments

Comments
 (0)