fix append error and decimal regex
This commit is contained in:
@@ -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"]]
|
||||
|
||||
@@ -74,29 +74,29 @@ df_reference_device = pd.DataFrame(denovix_reference_values).T
|
||||
df_reference_device.index.name = 'Solution'
|
||||
df_reference_device.columns.name = 'Wavelength'
|
||||
|
||||
df = pd.read_excel(curdir + path_delim + "data" + path_delim + "data_06_12_2023_12_47.xlsx", sheet_name="data")
|
||||
df = pd.read_excel(curdir + path_delim + "data" + path_delim + "data_19_02_2024_05_58.xlsx", sheet_name="data")
|
||||
|
||||
if not df.empty:
|
||||
conditions = [df['name'].str.contains('Tar', case=False, na=False),
|
||||
df['name'].str.contains('KM', case=False, na=False),
|
||||
conditions = [df['name'].str.contains('Tartrazine', case=False, na=False),
|
||||
df['name'].str.contains('Acid Red', case=False, na=False),
|
||||
df['name'].str.contains('HB', case=False, na=False)]
|
||||
|
||||
choices = ['Tartrazine', 'KMnO4', "HB"]
|
||||
choices = ['Tartrazine', 'Acid Red', "HB"]
|
||||
|
||||
df['solution'] = np.select(conditions, choices, default=None)
|
||||
|
||||
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['led2Average'] if row['solution'] == 'Tartrazine' else row['led1Average'], axis=1)
|
||||
|
||||
df_precision_acc = df[["deviceId", "solution", "concentration", "led1Average", "led2Average", "absorbance"]].groupby(["deviceId", "solution", "concentration"]).describe()["absorbance"][["count", "min", "max", "mean"]]
|
||||
@@ -195,7 +195,7 @@ if not df.empty:
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
filtered_df = df[df['solution'].isin(['KMnO4', 'Tartrazine', 'HB'])]
|
||||
filtered_df = df[df['solution'].isin(['Acid Red', 'Tartrazine', 'HB'])]
|
||||
|
||||
for solution in filtered_df['solution'].unique():
|
||||
if pd.notna(solution):
|
||||
@@ -224,7 +224,7 @@ if not df.empty:
|
||||
wks1.write(row, 3, str(r_value**2))
|
||||
|
||||
# Add the linear fit results to the new DataFrame
|
||||
df_linearfit_results = df_linearfit_results.append({'Solution': solution, 'Slope': slope, 'Intercept': intercept, 'R^2': r_value**2}, ignore_index=True)
|
||||
df_linearfit_results = df_linearfit_results._append({'Solution': solution, 'Slope': slope, 'Intercept': intercept, 'R^2': r_value**2}, ignore_index=True)
|
||||
|
||||
row += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user