-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_dataset_from_original_file.py
More file actions
57 lines (44 loc) · 1.35 KB
/
create_dataset_from_original_file.py
File metadata and controls
57 lines (44 loc) · 1.35 KB
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
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('data_svm_org_new_v2.csv')
X = dataset.iloc[:,0].values
y = dataset.iloc[:,1].values
column=[]
column.append('sample')
for i in range(1792):
a=list(X[i].split("_"))
if len(a)==4:
lhs,rhs=a[3].split(".")
col=lhs
elif len(a)==5:
lhs,rhs=a[4].split(".")
col=a[3]+"_"+lhs
elif len(a)==6:
lhs,rhs=a[5].split(".")
col=a[3]+"_"+a[4]+"_"+lhs
if col not in column:
column.append(col)
dataset1=pd.DataFrame(columns=column)
dataset1.fillna(0)
for i in range(1792):
a=list(X[i].split("_"))
classe=a[0]+"_"+a[1]+"_"+a[2]+".wav"
dataset1.set_value(i+1,'sample',classe)
dataset1=dataset1.drop_duplicates(keep='first')
for i in range(1792):
a=list(X[i].split("_"))
classe=a[0]+"_"+a[1]+"_"+a[2]+".wav"
if len(a)==4:
lhs,rhs=a[3].split(".")
col=lhs
elif len(a)==5:
lhs,rhs=a[4].split(".")
col=a[3]+"_"+lhs
elif len(a)==6:
lhs,rhs=a[5].split(".")
col=a[3]+"_"+a[4]+"_"+lhs
ind=dataset1.index[dataset1['sample'] == classe]
dataset1.set_value(ind,col,y[i])
dataset1=dataset1.reset_index()
dataset1=dataset1.drop('index',axis=1)
dataset1.to_csv("dataset.csv",index=False)