techmatik / utils.py
paulus5's picture
Create utils.py
1b73d5d verified
Raw
History Blame Contribute Delete
303 Bytes
import pandas as pd
import numpy as np
def detect_anomalies(csv_file):
df = pd.read_csv(csv_file)
column = df.columns[0]
values = df[column]
mean = values.mean()
std = values.std()
threshold = mean + 3 * std
df["anomaly"] = values > threshold
return df, threshold