Skip to content
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
8 changes: 4 additions & 4 deletions avaframe/in3Utils/cfgUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,13 +914,13 @@ def convertDF2numerics(simDF):
simDFTest = simDFTest.replace("-", "", regex=False)
# check for str(np.nan) as these cannot be converted to numerics by pd.to_numeric
# but as friction model parameters are set to nans this is required here
if simDFTest.str.match("nan").any():
if simDFTest.dropna().astype(str).eq("nan").any():
simDF = setStrnanToNan(simDF, simDFTest, name)
# also include columns where nan is in first row - so check for any row
if simDFTest.str.isdigit().any() and (name != "tSteps"):
# problem here is that it finds even if not present in | although not in ini
simDFTest = simDF[name].str.replace("|", "§", regex=False)
if simDFTest.str.contains("§").any() == False:
if simDFTest.astype(str).str.contains("§", regex=False).any() == False:
Comment thread
fso42 marked this conversation as resolved.
simDF[name] = pd.to_numeric(simDF[name])
log.debug("Converted to numeric %s" % name)
else:
Expand Down Expand Up @@ -950,10 +950,10 @@ def setStrnanToNan(simDF, simDFTest, name):

nanIndex = simDFTest.str.match("nan", flags=re.IGNORECASE)
simIndex = simDF.index.values
# loop over each row and use simDF.at to avoid copy vs view warning
# loop over each row and use iloc to avoid duplicate index issues
for index, nanInd in enumerate(nanIndex):
if nanInd:
simDF.at[simIndex[index], name] = np.nan
simDF.iloc[index, simDF.columns.get_loc(name)] = np.nan
log.info("%s for index: %s set to numpy nan" % (name, index))
return simDF

Expand Down
Loading