-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmerge.py
42 lines (32 loc) · 890 Bytes
/
merge.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
import os.path
import pandas as pd
filepath = '复现数据/'
pathDir = os.listdir(filepath)
data = pd.DataFrame()
i = 0
for allDir in pathDir:
# print(allDir)
o=open(filepath+'/'+allDir)
i+=1
data[allDir] = pd.read_csv(o)['label']
o.close()
result=pd.DataFrame()
def mean_data(filepath):
pathDir = os.listdir(filepath)
data = pd.DataFrame()
i = 0
for allDir in pathDir:
# print(allDir)
o=open(filepath+'/'+allDir)
i+=1
data[allDir] = pd.read_csv(o)['label']
o.close()
return data
result['sample_file_name']= pd.read_csv('new_data/submit_example.csv')['sample_file_name']
result['prediction']=list(map(lambda x:1 if x>0.45 else 0,data.mean(axis=1)))
file_name ='最终提交'
try:
os.mkdir(file_name)
except:
print('已存在')
result.to_csv(file_name+'/最终提交.csv',index=None)