[1]:
import transportation_tutorials as tt
import pandas as pd
import numpy as np
To answer the questions, use the following data:
[11]:
tour = pd.read_csv(tt.data('SERPM8-BASE2015-TOURS'))
tour.head()
[11]:
hh_id | person_id | person_num | person_type | tour_id | tour_category | tour_purpose | orig_mgra | dest_mgra | start_period | end_period | tour_mode | tour_distance | tour_time | atWork_freq | num_ob_stops | num_ib_stops | out_btap | out_atap | in_btap | in_atap | util_1 | util_2 | util_3 | util_4 | util_5 | util_6 | util_7 | util_8 | util_9 | util_10 | util_11 | util_12 | util_13 | util_14 | util_15 | util_16 | util_17 | util_18 | util_19 | util_20 | prob_1 | prob_2 | prob_3 | prob_4 | prob_5 | prob_6 | prob_7 | prob_8 | prob_9 | prob_10 | prob_11 | prob_12 | prob_13 | prob_14 | prob_15 | prob_16 | prob_17 | prob_18 | prob_19 | prob_20 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1690841 | 4502948 | 1 | 1 | 0 | MANDATORY | Work | 7736 | 9290 | 8 | 29 | 6 | 22.261 | 32.311001 | 6 | 0 | 0 | 0 | 0 | 0 | 0 | -1.395076 | -998.970825 | -2.360061 | -2.051275 | -2.361161 | -1.139561 | -999.0 | -999.0 | -996.401001 | -997.447021 | -996.244019 | -996.244019 | -997.664978 | -999.883789 | -999.883789 | -1001.335999 | -999.883789 | -999.883789 | -1001.335999 | -999.0 | 0.340576 | 0.0 | 0.000096 | 0.091587 | 0.000000 | 0.567742 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1 | 1690841 | 4502948 | 1 | 1 | 1 | AT_WORK | Work-Based | 9290 | 7980 | 13 | 14 | 1 | 1.910 | 4.752000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | -0.259837 | -998.668518 | -0.758937 | -999.608398 | -0.687137 | -999.858276 | -999.0 | -999.0 | -5.843162 | -28.534241 | -8.014107 | -1024.000000 | -1024.000000 | -30.581329 | -1024.000000 | -32.709736 | -30.581329 | -1024.000000 | -32.709736 | -999.0 | 0.555677 | 0.0 | 0.204790 | 0.000000 | 0.236415 | 0.000000 | 0.0 | 0.0 | 0.002799 | 0.0 | 0.000319 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
2 | 1690841 | 4502948 | 1 | 1 | 2 | AT_WORK | Work-Based | 9290 | 10608 | 19 | 23 | 3 | 1.357 | 3.777000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | -0.195235 | -998.668518 | -0.694335 | -999.608398 | -0.622535 | -999.858276 | -999.0 | -999.0 | -4.755019 | -28.262205 | -8.655456 | -1024.000000 | -1024.000000 | -33.426655 | -1024.000000 | -31.728464 | -33.426655 | -1024.000000 | -31.728464 | -999.0 | 0.553007 | 0.0 | 0.203806 | 0.000000 | 0.235279 | 0.000000 | 0.0 | 0.0 | 0.007751 | 0.0 | 0.000157 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
3 | 1690841 | 4502949 | 2 | 2 | 0 | MANDATORY | Work | 7736 | 8289 | 27 | 30 | 4 | 30.930 | 55.431000 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | -2.548089 | -998.970825 | -3.130183 | -1.918921 | -3.237083 | -1.397364 | -999.0 | -999.0 | -996.401001 | -997.447021 | -996.244019 | -996.244019 | -997.664978 | -999.883789 | -999.883789 | -1001.335999 | -999.883789 | -999.883789 | -1001.335999 | -999.0 | 0.068926 | 0.0 | 0.000000 | 0.242591 | 0.000000 | 0.688483 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
4 | 1690841 | 4502949 | 2 | 2 | 1 | MANDATORY | Work | 7736 | 8289 | 31 | 36 | 4 | 30.930 | 55.431000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | -2.493357 | -998.970825 | -3.075933 | -1.860832 | -3.182833 | -1.339275 | -999.0 | -999.0 | -996.401001 | -997.447021 | -996.244019 | -996.244019 | -997.664978 | -999.883789 | -999.883789 | -1001.335999 | -999.883789 | -999.883789 | -1001.335999 | -999.0 | 0.068497 | 0.0 | 0.000000 | 0.242703 | 0.000000 | 0.688801 | 0.0 | 0.0 | 0.000000 | 0.0 | 0.000000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
[13]:
tour_mode_dict = {
1: "DRIVEALONEFREE",
2: "DRIVEALONEPAY",
3: "SHARED2GP",
4: "SHARED2PAY",
5: "SHARED3GP",
6: "SHARED3PAY",
7: "TNCALONE",
8: "TNCSHARED",
9: "WALK",
10: "BIKE",
11: "WALK_MIX",
12: "WALK_PRMW",
13: "WALK_PRMD",
14: "PNR_MIX",
15: "PNR_PRMW",
16: "PNR_PRMD",
17: "KNR_MIX",
18: "KNR_PRMW",
19: "KNR_PRMD",
20: "SCHBUS",
}