fix append error and decimal regex

This commit is contained in:
Pritimay Sarkar
2024-02-19 12:04:46 +05:30
parent 3c599dd727
commit 439efbc1c9
2 changed files with 14 additions and 14 deletions

View File

@@ -184,16 +184,16 @@ def performance(request):
def extract_numbers(s):
if "HB" in s:
match = re.search(r'-(\d+)$', s)
match = re.search(r'-([\d.]+)$', s)
else:
match = re.search(r'-(\d+)', s) or re.search(r'(\d+)', s)
match = re.search(r'-([\d.]+)', s) or re.search(r'([\d.]+)', s)
if match:
return int(match.group(1))
return float(match.group(1))
else:
return None
df["concentration"] = df['name'].apply(extract_numbers)
df["concentration"] = df['name'].apply(extract_numbers)
df['absorbance'] = df.apply(lambda row: row['led1Average'] if row['solution'] == 'Tartrazine' else row['led3Average'], axis=1)
df_precision_acc = df[["deviceId", "solution", "concentration", "led1Average", "led3Average", "absorbance"]].groupby(["deviceId", "solution", "concentration"]).describe()["absorbance"][["count", "min", "max", "mean"]]