-
Notifications
You must be signed in to change notification settings - Fork 2
/
classify.py
executable file
·38 lines (30 loc) · 987 Bytes
/
classify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import csv
from datetime import datetime
import time
path = input("Enter the File name with .csv extension, default : 'data/clean-out.csv'.")
if path == "":
path = "data/clean-out.csv"
print(path)
df = pd.read_csv(path)
df['status'] = 0
#computing the mean value for given dataframe
std = df[['value']].std()
print ('std %.2f' % std)
#computing the mean value for dataframe
mean = df[['value']].mean()
print ('mean %.2f' % mean)
highThreshold = mean + std
lowThreshold = mean - std
print ('highThreshold %.2f' % highThreshold)
print ('lowThreshold %.2f' % lowThreshold)
for index, row in df.iterrows():
if (df.loc[index, 'value'] > highThreshold).bool() or (df.loc[index, 'value'] < lowThreshold).bool() :
df.loc[index,'status'] = '1'
#print(index)
new_df = df[df['status']!= 0]
del new_df['status']
new_df.to_csv('data/classify-out.csv', index=False)
print('data/classify-out.csv')