Skip to content
Snippets Groups Projects
Commit 6e8ccf7b authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

Modified preprocessing of dataframes before customload

parent 40160d20
No related branches found
No related tags found
No related merge requests found
......@@ -367,15 +367,18 @@ function preprocess_dataframe!(df::DataFrame)
for col in names(df)
col_type = eltype(df[!, col])
# Clamp values if range is defined for the column type
# Convert missing values to nothing for SQL NULL compatibility
df[!, col] = map(x -> ismissing(x) ? nothing : x, df[!, col])
# Clamp numeric values if range is defined for the column type
if haskey(SQL_RANGES, col_type)
min_val, max_val = SQL_RANGES[col_type]
df[!, col] = clamp.(df[!, col], min_val, max_val)
end
# Replace NaN and Inf with nothing for floating-point columns
# Replace NaN and Inf with nothing in numeric columns
if col_type <: AbstractFloat
df[!, col] = map(x -> isfinite(x) ? x : nothing, df[!, col])
end
end
end
\ No newline at end of file
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment