-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalues.py
66 lines (58 loc) · 1.42 KB
/
values.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pandas as pd
import numpy as np
def repl(dataframe,col):
a = []
maintainchar = ['unknown','Unknown','Null','null','','\0',np.nan]
maintainint = ['-','NaN','',np.nan]
count = 0
k=-1
reg = 0
print 'Do you want to replace value with something '
choice = False ## input choice here
value = 0 ## Enter the value here
if(choice):
if(dataframe[col].dtype == 'object'):
for i in dataframe[col].tolist():
count = count + 1
if(i in maintainchar):
print 'Record No ',count ,'has a problem'
reg = reg + 1
else:
for i in dataframe[col].tolist():
count = count + 1
if(i in maintainint):
print 'Record No ',count ,'has a problem'
reg = reg + 1
return reg
else:
li = []
if(dataframe[col].dtype == 'object'):
for i in dataframe[col].tolist():
##k=k+1
count = count+1
if(i in maintainchar):
print 'Record No ',count ,'has a problem'
li.append(value)
##dataframe.iloc[k][col] = value
reg = reg + 1
else:
li.append(i)
else:
li=[]
for i in dataframe[col].tolist():
count=count+1
##k = k + 1
if(i in maintainint):
print 'Record No ',count ,'has a problem'
##dataframe.loc[k,col] = value
li.append(value)
reg = reg + 1
else:
li.append(i)
dataframe[col].update(pd.Series(li))
return reg
df = pd.read_csv('bank-full.csv',';')
print df
k = asp(df,'poutcome')
print k
print df