-
Notifications
You must be signed in to change notification settings - Fork 1
/
drivers.py
57 lines (53 loc) · 1.38 KB
/
drivers.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
from functools import partial
from typing import Optional
from njdot.load import Years, load_tbl
from njdot.pedestrians import map_year_df, map_df
renames = {
'Year': 'year',
'Vehicle Number': 'vn',
**{
f'{c} {i}': f'{c.lower()}{i}'
for i in range(1, 5)
for c in ['Charge', 'Summons']
},
'Driver City': 'city',
'Driver State': 'state',
'Driver Zip Code': 'zip',
'Driver License State': 'license_state',
'Driver DOB': 'dob',
'Driver Sex': 'sex',
'Alcohol Test Given': 'alc_test_given',
'Alcohol Test Type': 'alc_test_type',
'Alcohol Test Results': 'alc_test_results',
'Driver Physical Status 1': 'status1',
'Driver Physical Status 2': 'status2',
}
astype = {
'vn': 'int8',
'status1': 'Int8',
'status2': 'Int8',
}
def load(
years: Years = None,
county: str = None,
read_pqt: Optional[bool] = None,
write_pqt: bool = False,
pqt_path: Optional[str] = None,
n_jobs: int = 0,
cols: Optional[list[str]] = None,
):
df = load_tbl(
'drivers',
years=years,
county=county,
renames=renames,
astype=astype,
cols=cols,
map_year_df=map_year_df,
map_df=partial(map_df, tpe='drivers'),
read_pqt=read_pqt,
write_pqt=write_pqt,
pqt_path=pqt_path,
n_jobs=n_jobs,
)
return df