Skip to content
Snippets Groups Projects

F fix strict values in table columns

Merged Florian Spreckelsen requested to merge f-fix-strict-values-in-table-columns into dev

Files

@@ -322,7 +322,7 @@ class TableImporter():
@@ -322,7 +322,7 @@ class TableImporter():
.. note::
.. note::
If columns are integer, but should be float, this method converts the respective columns
If columns are integer, but should be float, this method converts the respective columns
in place.
in place. The same for columns that should have string value but have numeric value.
Parameters
Parameters
----------
----------
@@ -338,9 +338,11 @@ class TableImporter():
@@ -338,9 +338,11 @@ class TableImporter():
# float, because CaosDB does not have different sizes anyway.
# float, because CaosDB does not have different sizes anyway.
col_dtype = df.dtypes[key]
col_dtype = df.dtypes[key]
if not strict and not np.issubdtype(col_dtype, datatype):
if not strict and not np.issubdtype(col_dtype, datatype):
issub = np.issubdtype
# These special cases should be fine.
# These special cases should be fine.
if issub(col_dtype, np.integer) and issub(datatype, np.floating):
if ((datatype == str)
 
or (np.issubdtype(col_dtype, np.integer)
 
and np.issubdtype(datatype, np.floating))
 
): # NOQA
df[key] = df[key].astype(datatype)
df[key] = df[key].astype(datatype)
# Now check each element
# Now check each element
Loading