Skip to content

Commit 50fdf42

Browse files
committed
additional commit
1 parent 7e4354d commit 50fdf42

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/petab_gui/commands.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,18 @@ def _apply_changes(self, use_new: bool):
304304
df[col] = df[col].astype(dtype)
305305
elif np.issubdtype(dtype, np.number):
306306
df[col] = pd.to_numeric(df[col], errors="coerce")
307+
# If original dtype was integer and column has NaN, use nullable Int type
308+
if np.issubdtype(dtype, np.integer) and df[col].isna().any():
309+
if dtype == np.int64:
310+
df[col] = df[col].astype("Int64")
311+
elif dtype == np.int32:
312+
df[col] = df[col].astype("Int32")
313+
elif dtype == np.int16:
314+
df[col] = df[col].astype("Int16")
315+
elif dtype == np.int8:
316+
df[col] = df[col].astype("Int8")
317+
else:
318+
df[col] = df[col].astype("Int64")
307319
else:
308320
df[col] = df[col].astype(dtype)
309321

0 commit comments

Comments
 (0)