-
Notifications
You must be signed in to change notification settings - Fork 0
/
02.merge.py
62 lines (38 loc) · 1.06 KB
/
02.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import os, sys
import pandas as pd
import numpy as np
from glob import glob
# In[2]:
days = sorted(
glob('./huabei/wanlong/*'),
key = lambda x: int( os.path.basename(x) )
)
# In[3]:
for day in days:
print (os.path.basename(day) )
files = sorted(
glob( os.path.join(day,'*.pkl') ),
key = lambda x: int( os.path.basename(x)[:-4] )
)
sum_df = pd.DataFrame()
for file in files:
df = pd.read_pickle(file)
sum_df = sum_df.append(df, ignore_index=True)
sum_df.astype(
{
'x1' : np.int16,
'x2' : np.int16,
'y1' : np.int16,
'y2' : np.int16,
}
).to_pickle( os.path.join('bulk',os.path.basename(day)+'.pkl') )
# break
# In[4]:
days = sorted( [os.path.basename(i) for i in glob('./huabei/wanlong/*')] )
for idx,day in enumerate(days):
data_df = pd.read_pickle('./bulk/'+day+'.pkl')
data_df['ref_day'] = np.int16(idx)
data_df.to_csv('./bulk/'+day+'.csv.gz',index=False)