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

Handle NaN values in String columns correctly #11

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion omero2pandas/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def generate_omero_columns(df):
max_len = df[column_name].str.len().max()
if math.isnan(max_len):
max_len = 1
col = col_class(cleaned_name, "", max_len, [])
col = col_class(cleaned_name, "", int(max_len), [])
# Coerce missing values into strings
df[column_name].fillna('', inplace=True)
else:
col = col_class(cleaned_name, "", [])
omero_columns.append(col)
Expand All @@ -85,6 +87,7 @@ def create_table(df, table_name, parent_id, parent_type, conn, chunk_size):
raise ValueError(f"{parent_type} ID {parent_id} not found")
parent_group = parent_ob.details.group.id.val

df = df.copy()
orig_columns = df.columns.tolist()
columns = generate_omero_columns(df)
resources = conn.c.sf.sharedResources(_ctx={
Expand Down