sourav11295 commited on
Commit
44dc288
·
1 Parent(s): 16da787

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -26,17 +26,21 @@ def read(file,dep,ord):
26
  for col in df.columns.values:
27
  if str(df.dtypes[col]) == 'bool' or str(df.dtypes[col]) == 'object':
28
  cat.append(col)
 
 
 
 
 
29
  nom = list(set(cat).difference(set(ord)))
 
30
  new_df = df.dropna(axis=0)
31
- if str(ord) != "":
32
- ord = ord.split(',')
33
- le = LabelEncoder()
34
- new_df[ord] = new_df[ord].apply(lambda col: le.fit_transform(col))
35
- else:
36
  pass
37
- ohe_df = pd.get_dummies(new_df[nom], drop_first=True)
38
- new_df.drop(columns=nom, axis=1,inplace=True)
39
- new_df = pd.concat([new_df,ohe_df],axis=1)
 
40
  if dep_type == 'bool' or dep_type == 'object':
41
  text = "classification"
42
  result = classification(new_df,dep)
 
26
  for col in df.columns.values:
27
  if str(df.dtypes[col]) == 'bool' or str(df.dtypes[col]) == 'object':
28
  cat.append(col)
29
+ if ord == "":
30
+ ord = list()
31
+ else:
32
+ ord = ord.split(',')
33
+ ord.append(dep)
34
  nom = list(set(cat).difference(set(ord)))
35
+ le = LabelEncoder()
36
  new_df = df.dropna(axis=0)
37
+ new_df[ord] = new_df[ord].apply(lambda col: le.fit_transform(col))
38
+ if len(nom) == 0:
 
 
 
39
  pass
40
+ else:
41
+ ohe_df = pd.get_dummies(new_df[nom], drop_first=True)
42
+ new_df.drop(columns=nom, axis=1,inplace=True)
43
+ new_df = pd.concat([new_df,ohe_df],axis=1)
44
  if dep_type == 'bool' or dep_type == 'object':
45
  text = "classification"
46
  result = classification(new_df,dep)