assign_cars_to_households(year, area, classifier)
Assign car ownership to households based on a classifier model.
This function assigns car ownership to households in the specified year and area using a pre-trained classifier model. It predicts the probability of car ownership for each household and assigns cars based on the top predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which to assign car ownership. |
required |
area |
str
|
The geographical area for which to assign car ownership. |
required |
classifier |
object
|
The pre-trained classifier model for predicting car ownership. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Fetches car ownership data for the specified year and area. 2. Preprocesses household data for model input. 3. Predicts the probability of car ownership for each household. 4. Assigns car ownership based on the top predictions. 5. Caps the number of cars per household to a specified maximum. 6. Logs the total number of cars after capping.
Source code in tripsender\utils.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
|
assign_children_to_households(year, area, children, age_split, min_age_of_parent=25)
Assign children to households based on age and probability data.
This function assigns children to households for the specified year and area using probability data and age-based categorization. It splits households into different categories based on the age of the head and assigns children accordingly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which to assign children. |
required |
area |
str
|
The geographical area for which to assign children. |
required |
children |
list
|
The list of children to be assigned. |
required |
age_split |
int
|
The age threshold to categorize households. |
required |
min_age_of_parent |
int
|
The minimum age for a parent. Defaults to 25. |
25
|
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Determines if a household has children based on probability data. 2. Splits households into different categories based on the age of the head. 3. Assigns the number of children to each household based on the probability matrix. 4. Randomly adjusts the number of children in households to match the total number of children. 5. Matches children to households based on the number of children needed. 6. Updates the has_child attribute for each person in the household. 7. Logs the assignment process and results.
Source code in tripsender\utils.py
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
|
assign_house_type_to_households(year, area)
Assign house types to households based on probability data (improved method).
This function assigns house types to households in the specified year and area using probability data fetched from external sources. It uses an improved method that accounts for varying household sizes and assigns house types accordingly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which to assign house types. |
required |
area |
str
|
The geographical area for which to assign house types. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Fetches probability data for house types based on the specified year and area. 2. Maps household sizes to the corresponding house type key, with special handling for larger households. 3. Iterates through each household to assign house types based on the probability data. 4. Logs any cases where valid house type data is not available for certain household sizes.
Source code in tripsender\utils.py
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 |
|
assign_house_type_to_households_old(year, area)
Assign house types to households based on probability data (old method).
This function assigns house types to households in the specified year and area using probability data fetched from external sources. It uses an older method that directly maps household sizes to house types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which to assign house types. |
required |
area |
str
|
The geographical area for which to assign house types. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Fetches probability data for house types based on the specified year and area. 2. Maps household sizes to the corresponding house type key. 3. Assigns house types to households based on the probability data. 4. Logs any cases where household size does not match the probability data.
Source code in tripsender\utils.py
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
|
assign_primary_status_to_members(year, area, classifier)
Assign primary status (e.g., work, education, home) to household members.
This function assigns primary status to household members for the specified year and area using a pre-trained classifier model. It predicts the probability of different primary statuses for each individual and assigns the status based on the top predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which to assign primary status. |
required |
area |
str
|
The geographical area for which to assign primary status. |
required |
classifier |
object
|
The pre-trained classifier model for predicting primary status. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Fetches primary status data for the specified year and area. 2. Preprocesses household data for model input. 3. Predicts the probability of different primary statuses for each individual. 4. Assigns primary status to individuals based on the top predictions. 5. Logs the distribution of primary status among the household members.
Source code in tripsender\utils.py
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
|
assign_primary_status_to_members_backup(classifier)
Assign primary status (e.g., work, education, home) to household members using a backup method.
This function assigns primary status to household members using a pre-trained classifier model. It predicts the primary status for each individual based on household data and assigns the corresponding status to each member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classifier |
object
|
The pre-trained classifier model for predicting primary status. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Preprocesses household data for model input. 2. Predicts the primary status for each individual using the classifier. 3. Assigns the predicted primary status to each member. 4. Logs the distribution of primary status among the household members.
Source code in tripsender\utils.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
|
balance_lists(p1, p2)
Balance the lengths of two lists by moving excess individuals to a separate list.
This function ensures that the two input lists have the same length by moving excess individuals from the longer list to a separate list of unmatched individuals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p1 |
list
|
The first list of individuals. |
required |
p2 |
list
|
The second list of individuals. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the balanced lists and the list of unmatched individuals. |
The function performs the following steps: 1. Checks if the lengths of the two lists are equal. 2. If not, calculates the difference in lengths and moves excess individuals to a separate list. 3. Returns the balanced lists and the list of unmatched individuals.
Source code in tripsender\utils.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
|
calculate_similarity(query, area)
Calculate the similarity between the query and the area.
This function calculates the similarity score between the query string and the area string based on various criteria such as exact match, missing characters, and common characters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The query string. |
required |
area |
str
|
The area string to compare with the query. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
The similarity score between the query and the area. |
The function performs the following steps: 1. Checks for an exact match and returns a high similarity score if found. 2. Checks for missing characters and returns a high similarity score if found. 3. Calculates the similarity based on the number of common characters between the query and the area. 4. Returns the similarity score.
Source code in tripsender\utils.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
cap_cars_per_household(households, max_cars=4)
Cap the number of cars per household to a specified maximum.
This function ensures that no household has more than the specified maximum number of cars. If a household has more cars than the specified maximum, the excess cars are removed and the car ownership status of individuals is updated accordingly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
households |
list
|
The list of Household instances. |
required |
max_cars |
int
|
The maximum number of cars allowed per household. Defaults to 4. |
4
|
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Iterates through each household in the list. 2. Checks if the household has more cars than the specified maximum. 3. If so, removes the excess cars and updates the car ownership status of individuals.
Source code in tripsender\utils.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
clear_instances()
Clear all instances of Population, Person, House, Household, Building, and ActivitySequence.
This function clears all instances of the specified classes to reset the data. It ensures that no residual data remains from previous runs.
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Clears all instances of the Population class. 2. Clears all instances of the Person class. 3. Clears all instances of the House class. 4. Clears all instances of the Household class. 5. Clears all instances of the Building class. 6. Clears all instances of the ActivitySequence class.
Source code in tripsender\utils.py
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
|
couples_from_individuals(p1, p2)
Create couples from two lists of individuals and form households.
This function matches individuals from two lists (e.g., males and females) to create couples and form households. It balances the lists, matches individuals based on age, and creates Household instances for each couple.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p1 |
list
|
The first list of individuals (e.g., males). |
required |
p2 |
list
|
The second list of individuals (e.g., females). |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the number of households created and the list of Household instances. |
The function performs the following steps: 1. Balances the lengths of the two lists. 2. Matches individuals from the two lists based on age and other criteria. 3. Creates Household instances for each matched couple. 4. Returns the number of households created and the list of Household instances.
Source code in tripsender\utils.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
get_older_child_probability_matrix(older_children_data)
Calculate the probability matrix for households with older children (aged 25+ years).
This function processes the input data to calculate the probability of households having older children. It returns a dictionary with the probability of having older children in different household categories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
older_children_data |
dict
|
The input data containing information on households with older children. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the probability matrix for households with older children. |
The function performs the following steps: 1. Processes the input data to extract household categories and the count of older children. 2. Calculates the total number of households with older children. 3. Calculates the probability of having older children in each household category. 4. Returns the resulting probability matrix.
Source code in tripsender\utils.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
get_probability_of_children(year, area)
Calculate the probability of having children in different household types.
This function fetches data on households with children for the specified year and area, processes the data to calculate the probability of having children in different household types, and returns the calculated probabilities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which the data is to be fetched. |
required |
area |
str
|
The geographical area for which the data is to be fetched. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the probability of having children in each household type. |
The function performs the following steps: 1. Fetches data on households with children for the specified year and area. 2. Processes the data to calculate the total number of households in each household type. 3. Calculates the probability of having children in each household type based on the fetched data. 4. Returns the calculated probabilities.
Source code in tripsender\utils.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
get_probability_of_housetype(year, area)
Calculate the probability of different household types in a given area.
This function fetches data on household types for the specified year and area, processes the data to calculate the probability of each household type, and returns the calculated probabilities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which the data is to be fetched. |
required |
area |
str
|
The geographical area for which the data is to be fetched. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the probability of each household type in the area. |
The function performs the following steps: 1. Fetches data on household types for the specified year and area. 2. Processes the data to map household types to simplified categories. 3. Calculates the total number of households in each category. 4. Calculates the percentage of each household type based on the fetched data. 5. Returns the calculated probabilities.
Source code in tripsender\utils.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
get_younger_child_probability_matrix(data)
Calculate the probability matrix for the number of younger children in households.
This function processes the input data to calculate the probability of having a certain number of younger children in different household categories. It returns the resulting probability matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
The input data containing household information. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the probability matrix for the number of younger children in households. |
The function performs the following steps: 1. Renames household types in the input data to simplified categories. 2. Merges data for similar household types. 3. Creates a nested dictionary with the count of younger children for each household category. 4. Calculates the probability of having a certain number of younger children in each household category. 5. Returns the resulting probability matrix.
Source code in tripsender\utils.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
impute_municipal_children_count(year, area)
Impute the count of children in households within a municipality based on provided data.
This function fetches municipal children data for the specified year and area, processes the data to impute the count of children in different household categories, and returns the imputed data as dictionaries for households with children aged 0-24 years and 25 years or older.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year |
int
|
The year for which the data is to be fetched. |
required |
area |
str
|
The geographical area for which the data is to be fetched. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
Two dictionaries containing imputed children counts for households with children aged 0-24 years and 25 years or older. |
The function performs the following steps: 1. Fetches municipal children data for the specified year and area. 2. Processes the data to create a nested dictionary with children counts for different household categories. 3. Transforms the data to calculate the probability of having a certain number of children in each household category. 4. Separates the data into two dictionaries based on the age of children (0-24 years and 25 years or older). 5. Returns the two dictionaries with imputed children counts.
Source code in tripsender\utils.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
match_child_to_parent(parent, list_of_children, min_age_of_parent=20, initial_tolerance=5, max_tolerance=20, tolerance_increment=2)
Match a child to a parent based on age and add the child to the parent's household.
This function matches a child to a parent from the list of children based on the age difference between the parent and the child. It uses a tolerance range to find a suitable match and adds the matched child to the parent's household.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
Person
|
The parent individual. |
required |
list_of_children |
list
|
The list of child individuals to match. |
required |
min_age_of_parent |
int
|
The minimum age for a parent. Defaults to 20. |
20
|
initial_tolerance |
int
|
The initial tolerance range for matching. Defaults to 5. |
5
|
max_tolerance |
int
|
The maximum tolerance range for matching. Defaults to 20. |
20
|
tolerance_increment |
int
|
The increment in tolerance range for each iteration. Defaults to 2. |
2
|
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Calculates the proxy age of the child based on the parent's age and minimum age of parent. 2. Iterates through the list of children to find a match within the initial tolerance range. 3. If no match is found, increases the tolerance range and retries until the maximum tolerance is reached. 4. Adds the matched child to the parent's household and removes the child from the list of children. 5. Logs the matching process and results.
Source code in tripsender\utils.py
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
|
match_list_household_children(list_household, list_children)
Match children to households based on the number of children needed.
This function matches children to households based on the number of children each household needs. It expands the household list based on the number of children required and pairs each child with a household.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
list_household |
list
|
The list of households. |
required |
list_children |
list
|
The list of children to be matched. |
required |
Returns:
Type | Description |
---|---|
None |
The function performs the following steps: 1. Expands the household list based on the number of children needed in each household. 2. Sorts the household list based on the age of a randomly chosen parent. 3. Sorts the children list by age. 4. Pairs each child with a household and adds the child to the household. 5. Logs the matching process and results.
Source code in tripsender\utils.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
|
parse_num_children(data)
Parse the number of children from a string.
This function extracts the number of children from the given data string using regular expressions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
str
|
The input string containing the number of children. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
The number of children extracted from the input string. Returns 0 if no number is found. |
Example
parse_num_children("3 children") 3
Source code in tripsender\utils.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
preprocess_household_data(aligned_columns=[], drop=[], onehotencode=False)
Preprocess household data for model input.
This function preprocesses household data by ensuring all required columns are present, dropping specified columns, and optionally one-hot encoding categorical variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aligned_columns |
list
|
List of columns to ensure are present in the DataFrame. |
[]
|
drop |
list
|
List of columns to drop from the DataFrame. |
[]
|
onehotencode |
bool
|
Whether to one-hot encode categorical variables. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the preprocessed DataFrame and the list of adult individuals. |
The function performs the following steps: 1. Fetches household data and adult individuals. 2. Ensures all specified columns are present in the DataFrame. 3. Drops specified columns from the DataFrame. 4. Optionally one-hot encodes categorical variables. 5. Returns the preprocessed DataFrame and the list of adult individuals.
Source code in tripsender\utils.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 |
|
sample_children_category(probability_matrix, household_type)
Sample a children category based on the probability matrix for the given household type.
This function uses the provided probability matrix to randomly sample a children category for the specified household type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
probability_matrix |
dict
|
The probability matrix for children categories. |
required |
household_type |
str
|
The household type for which to sample a children category. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
The sampled children category. Returns None if the household type is not found in the probability matrix. |
The function performs the following steps: 1. Checks if the household type exists in the probability matrix. 2. Extracts children categories and their corresponding probabilities from the probability matrix. 3. Randomly samples a children category based on the extracted probabilities. 4. Returns the sampled children category.
Source code in tripsender\utils.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
sample_household_for_older_child(probability_matrix)
Sample a household type based on the probability matrix for older children.
This function uses the provided probability matrix to randomly sample a household type that is likely to have older children.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
probability_matrix |
dict
|
The probability matrix for households with older children. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The sampled household type. |
The function performs the following steps: 1. Extracts household categories and their corresponding probabilities from the probability matrix. 2. Randomly samples a household type based on the extracted probabilities. 3. Returns the sampled household type.
Source code in tripsender\utils.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
|
search_primary_area(query, df=pd.read_csv(PATH_PRIMARY_AREA))
Search for the best matching primary area from the DataFrame based on the query.
This function takes a query string and searches for the best matching primary area from the given DataFrame. It calculates the similarity between the query and each primary area in the DataFrame, and returns the best match.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The query string to search for. |
required |
df |
DataFrame
|
The DataFrame containing primary areas. Defaults to reading from PATH_PRIMARY_AREA. |
read_csv(PATH_PRIMARY_AREA)
|
Returns:
Name | Type | Description |
---|---|---|
str |
The best matching primary area. |
The function performs the following steps: 1. Converts the query to lowercase for case-insensitive comparison. 2. Iterates through each primary area in the DataFrame, converting it to lowercase. 3. Calculates the similarity between the query and the current primary area. 4. Updates the best match if the current primary area has a higher similarity score. 5. Returns the best matching primary area.
Source code in tripsender\utils.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
split_households_by_householdtype()
Split individuals into different lists based on their household type.
This function splits individuals into different lists based on their household type, such as children, single parents, living alone, married, cohabiting, and others.
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing lists of individuals for each household type. |
The function performs the following steps: 1. Iterates through each individual and categorizes them based on their household type. 2. Adds the individuals to the corresponding list for their household type. 3. Logs the number of individuals in each household type. 4. Returns the lists of individuals for each household type.
Source code in tripsender\utils.py
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
|