File size: 75,364 Bytes
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
b18457f
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
b18457f
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
b18457f
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
b18457f
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
b18457f
b1a5491
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
6a0acc8
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
 
b18457f
 
b1a5491
b18457f
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
6a0acc8
 
b1a5491
 
 
 
 
 
 
 
6a0acc8
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
6a0acc8
 
b1a5491
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
6a0acc8
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
 
 
 
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
b18457f
 
b1a5491
 
 
 
b18457f
 
b1a5491
 
 
 
b18457f
 
b1a5491
 
 
 
b18457f
 
b1a5491
 
 
 
b18457f
 
 
 
 
 
 
b1a5491
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
6a0acc8
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
 
 
 
 
 
 
b18457f
 
 
b1a5491
 
 
 
 
 
 
 
 
 
b18457f
 
 
b1a5491
 
 
 
 
 
 
 
 
 
b18457f
 
 
b1a5491
 
 
 
 
 
 
 
 
 
b18457f
 
 
b1a5491
 
 
 
 
 
 
 
 
 
b18457f
 
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
6a0acc8
b1a5491
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
b18457f
 
6a0acc8
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b18457f
 
 
 
 
 
6a0acc8
b1a5491
6a0acc8
b1a5491
 
 
b18457f
 
 
 
 
 
 
 
6a0acc8
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
6a0acc8
b1a5491
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
b1a5491
 
 
 
 
 
 
b18457f
 
 
 
 
 
b1a5491
 
 
 
 
 
b18457f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
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
100
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
142
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
257
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
325
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
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
476
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
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
573
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
612
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
691
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
724
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
753
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
811
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
873
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
931
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
1011
1012
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
1074
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
1121
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
1182
1183
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
1227
1228
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
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Importing required packages\n",
    "import pandas as pd\n",
    "\n",
    "# setting default option\n",
    "pd.set_option(\"mode.copy_on_write\", True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Notes</th>\n",
       "      <th>State</th>\n",
       "      <th>State Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County Code</th>\n",
       "      <th>Yearly July 1st Estimates</th>\n",
       "      <th>Yearly July 1st Estimates Code</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16408</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Michigan</td>\n",
       "      <td>26.0</td>\n",
       "      <td>Gogebic County, MI</td>\n",
       "      <td>26053.0</td>\n",
       "      <td>2005.0</td>\n",
       "      <td>2005.0</td>\n",
       "      <td>16811</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38823</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Washington</td>\n",
       "      <td>53.0</td>\n",
       "      <td>Pierce County, WA</td>\n",
       "      <td>53053.0</td>\n",
       "      <td>2008.0</td>\n",
       "      <td>2008.0</td>\n",
       "      <td>785400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40791</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Wyoming</td>\n",
       "      <td>56.0</td>\n",
       "      <td>Lincoln County, WY</td>\n",
       "      <td>56023.0</td>\n",
       "      <td>2013.0</td>\n",
       "      <td>2013.0</td>\n",
       "      <td>18342</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39130</th>\n",
       "      <td>NaN</td>\n",
       "      <td>West Virginia</td>\n",
       "      <td>54.0</td>\n",
       "      <td>Grant County, WV</td>\n",
       "      <td>54023.0</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>11406</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22278</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Nebraska</td>\n",
       "      <td>31.0</td>\n",
       "      <td>Lancaster County, NE</td>\n",
       "      <td>31109.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>293515</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Notes          State  State Code                County  County Code  \\\n",
       "16408   NaN       Michigan        26.0    Gogebic County, MI      26053.0   \n",
       "38823   NaN     Washington        53.0     Pierce County, WA      53053.0   \n",
       "40791   NaN        Wyoming        56.0    Lincoln County, WY      56023.0   \n",
       "39130   NaN  West Virginia        54.0      Grant County, WV      54023.0   \n",
       "22278   NaN       Nebraska        31.0  Lancaster County, NE      31109.0   \n",
       "\n",
       "       Yearly July 1st Estimates  Yearly July 1st Estimates Code Population  \n",
       "16408                     2005.0                          2005.0      16811  \n",
       "38823                     2008.0                          2008.0     785400  \n",
       "40791                     2013.0                          2013.0      18342  \n",
       "39130                     2003.0                          2003.0      11406  \n",
       "22278                     2012.0                          2012.0     293515  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Load Raw Data File\n",
    "df = pd.read_csv(\"../.01_Data/01_Raw/raw_population.txt\", sep=\"\\t\")\n",
    "df.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 41037 entries, 0 to 41036\n",
      "Data columns (total 8 columns):\n",
      " #   Column                          Non-Null Count  Dtype  \n",
      "---  ------                          --------------  -----  \n",
      " 0   Notes                           100 non-null    object \n",
      " 1   State                           40937 non-null  object \n",
      " 2   State Code                      40937 non-null  float64\n",
      " 3   County                          40937 non-null  object \n",
      " 4   County Code                     40937 non-null  float64\n",
      " 5   Yearly July 1st Estimates       40937 non-null  float64\n",
      " 6   Yearly July 1st Estimates Code  40937 non-null  float64\n",
      " 7   Population                      40937 non-null  object \n",
      "dtypes: float64(4), object(4)\n",
      "memory usage: 2.5+ MB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Notes</th>\n",
       "      <th>State</th>\n",
       "      <th>State Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County Code</th>\n",
       "      <th>Yearly July 1st Estimates</th>\n",
       "      <th>Yearly July 1st Estimates Code</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>40937</th>\n",
       "      <td>---</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40938</th>\n",
       "      <td>Dataset: Bridged-Race Population Estimates 199...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40939</th>\n",
       "      <td>Query Parameters:</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40940</th>\n",
       "      <td>Yearly July 1st Estimates: 2003; 2004; 2005; 2...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40941</th>\n",
       "      <td>Group By: State; County; Yearly July 1st Estim...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41032</th>\n",
       "      <td>City are available only for the years prior to...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41033</th>\n",
       "      <td>1999 and 2000 due to the addition of population.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41034</th>\n",
       "      <td>20. South Boston City, Virginia (FIPS code 517...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41035</th>\n",
       "      <td>June 30, 1995. This change was made retroactiv...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41036</th>\n",
       "      <td>have been reported with Halifax County since y...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   Notes State  State Code  \\\n",
       "40937                                                ---   NaN         NaN   \n",
       "40938  Dataset: Bridged-Race Population Estimates 199...   NaN         NaN   \n",
       "40939                                  Query Parameters:   NaN         NaN   \n",
       "40940  Yearly July 1st Estimates: 2003; 2004; 2005; 2...   NaN         NaN   \n",
       "40941  Group By: State; County; Yearly July 1st Estim...   NaN         NaN   \n",
       "...                                                  ...   ...         ...   \n",
       "41032  City are available only for the years prior to...   NaN         NaN   \n",
       "41033   1999 and 2000 due to the addition of population.   NaN         NaN   \n",
       "41034  20. South Boston City, Virginia (FIPS code 517...   NaN         NaN   \n",
       "41035  June 30, 1995. This change was made retroactiv...   NaN         NaN   \n",
       "41036  have been reported with Halifax County since y...   NaN         NaN   \n",
       "\n",
       "      County  County Code  Yearly July 1st Estimates  \\\n",
       "40937    NaN          NaN                        NaN   \n",
       "40938    NaN          NaN                        NaN   \n",
       "40939    NaN          NaN                        NaN   \n",
       "40940    NaN          NaN                        NaN   \n",
       "40941    NaN          NaN                        NaN   \n",
       "...      ...          ...                        ...   \n",
       "41032    NaN          NaN                        NaN   \n",
       "41033    NaN          NaN                        NaN   \n",
       "41034    NaN          NaN                        NaN   \n",
       "41035    NaN          NaN                        NaN   \n",
       "41036    NaN          NaN                        NaN   \n",
       "\n",
       "       Yearly July 1st Estimates Code Population  \n",
       "40937                             NaN        NaN  \n",
       "40938                             NaN        NaN  \n",
       "40939                             NaN        NaN  \n",
       "40940                             NaN        NaN  \n",
       "40941                             NaN        NaN  \n",
       "...                               ...        ...  \n",
       "41032                             NaN        NaN  \n",
       "41033                             NaN        NaN  \n",
       "41034                             NaN        NaN  \n",
       "41035                             NaN        NaN  \n",
       "41036                             NaN        NaN  \n",
       "\n",
       "[100 rows x 8 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# View the rows which have text values in notes column\n",
    "df[df[\"Notes\"].notnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# droping notes column\n",
    "df1 = df.drop(columns=[\"Notes\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# removing the rows with na values generated due to Notes, using state column for reference\n",
    "df1 = df1.dropna(subset=[\"State\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# dropping alaska\n",
    "df1 = df1[df1[\"State\"] != \"Alaska\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County Code</th>\n",
       "      <th>Yearly July 1st Estimates</th>\n",
       "      <th>Yearly July 1st Estimates Code</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>26545</th>\n",
       "      <td>North Dakota</td>\n",
       "      <td>38.0</td>\n",
       "      <td>Stutsman County, ND</td>\n",
       "      <td>38093.0</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>2015.0</td>\n",
       "      <td>21090</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23363</th>\n",
       "      <td>New Jersey</td>\n",
       "      <td>34.0</td>\n",
       "      <td>Sussex County, NJ</td>\n",
       "      <td>34037.0</td>\n",
       "      <td>2005.0</td>\n",
       "      <td>2005.0</td>\n",
       "      <td>150192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35046</th>\n",
       "      <td>Texas</td>\n",
       "      <td>48.0</td>\n",
       "      <td>Mitchell County, TX</td>\n",
       "      <td>48335.0</td>\n",
       "      <td>2014.0</td>\n",
       "      <td>2014.0</td>\n",
       "      <td>9075</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13607</th>\n",
       "      <td>Kentucky</td>\n",
       "      <td>21.0</td>\n",
       "      <td>Harrison County, KY</td>\n",
       "      <td>21097.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>18612</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12325</th>\n",
       "      <td>Kansas</td>\n",
       "      <td>20.0</td>\n",
       "      <td>Lyon County, KS</td>\n",
       "      <td>20111.0</td>\n",
       "      <td>2004.0</td>\n",
       "      <td>2004.0</td>\n",
       "      <td>36034</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              State  State Code               County  County Code  \\\n",
       "26545  North Dakota        38.0  Stutsman County, ND      38093.0   \n",
       "23363    New Jersey        34.0    Sussex County, NJ      34037.0   \n",
       "35046         Texas        48.0  Mitchell County, TX      48335.0   \n",
       "13607      Kentucky        21.0  Harrison County, KY      21097.0   \n",
       "12325        Kansas        20.0      Lyon County, KS      20111.0   \n",
       "\n",
       "       Yearly July 1st Estimates  Yearly July 1st Estimates Code Population  \n",
       "26545                     2015.0                          2015.0      21090  \n",
       "23363                     2005.0                          2005.0     150192  \n",
       "35046                     2014.0                          2014.0       9075  \n",
       "13607                     2012.0                          2012.0      18612  \n",
       "12325                     2004.0                          2004.0      36034  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 40495 entries, 0 to 40936\n",
      "Data columns (total 7 columns):\n",
      " #   Column                          Non-Null Count  Dtype  \n",
      "---  ------                          --------------  -----  \n",
      " 0   State                           40495 non-null  object \n",
      " 1   State Code                      40495 non-null  float64\n",
      " 2   County                          40495 non-null  object \n",
      " 3   County Code                     40495 non-null  float64\n",
      " 4   Yearly July 1st Estimates       40495 non-null  float64\n",
      " 5   Yearly July 1st Estimates Code  40495 non-null  float64\n",
      " 6   Population                      40495 non-null  object \n",
      "dtypes: float64(4), object(3)\n",
      "memory usage: 2.5+ MB\n"
     ]
    }
   ],
   "source": [
    "df1.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# validate if yealry estimate and estimate code are same\n",
    "df1[\"Yearly July 1st Estimates\"].equals(df1[\"Yearly July 1st Estimates Code\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Correcting Data Types\n",
    "df2 = df1.copy()\n",
    "\n",
    "# Saving state code as padded string\n",
    "df2[\"State Code\"] = df2[\"State Code\"].astype(int).astype(str).str.zfill(2)\n",
    "\n",
    "# Saving county code as padded string\n",
    "df2[\"County Code\"] = df2[\"County Code\"].astype(int).astype(str).str.zfill(5)\n",
    "\n",
    "# Converting Year to Integer\n",
    "df2[\"Yearly July 1st Estimates\"] = df2[\"Yearly July 1st Estimates\"].astype(int)\n",
    "\n",
    "# Converting Population to Integer\n",
    "# replacing the missing values with 0 for now\n",
    "df2[\"Population\"] = df2[\"Population\"].replace(\"Missing\", 0)\n",
    "df2[\"Population\"] = df2[\"Population\"].astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County Code</th>\n",
       "      <th>Yearly July 1st Estimates</th>\n",
       "      <th>Yearly July 1st Estimates Code</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18532</th>\n",
       "      <td>Mississippi</td>\n",
       "      <td>28</td>\n",
       "      <td>George County, MS</td>\n",
       "      <td>28039</td>\n",
       "      <td>2010</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>22653</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20169</th>\n",
       "      <td>Missouri</td>\n",
       "      <td>29</td>\n",
       "      <td>Marion County, MO</td>\n",
       "      <td>29127</td>\n",
       "      <td>2009</td>\n",
       "      <td>2009.0</td>\n",
       "      <td>28720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17948</th>\n",
       "      <td>Minnesota</td>\n",
       "      <td>27</td>\n",
       "      <td>Ramsey County, MN</td>\n",
       "      <td>27123</td>\n",
       "      <td>2011</td>\n",
       "      <td>2011.0</td>\n",
       "      <td>515856</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37444</th>\n",
       "      <td>Virginia</td>\n",
       "      <td>51</td>\n",
       "      <td>Madison County, VA</td>\n",
       "      <td>51113</td>\n",
       "      <td>2007</td>\n",
       "      <td>2007.0</td>\n",
       "      <td>13429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24046</th>\n",
       "      <td>New York</td>\n",
       "      <td>36</td>\n",
       "      <td>Franklin County, NY</td>\n",
       "      <td>36033</td>\n",
       "      <td>2012</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>51791</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             State State Code               County County Code  \\\n",
       "18532  Mississippi         28    George County, MS       28039   \n",
       "20169     Missouri         29    Marion County, MO       29127   \n",
       "17948    Minnesota         27    Ramsey County, MN       27123   \n",
       "37444     Virginia         51   Madison County, VA       51113   \n",
       "24046     New York         36  Franklin County, NY       36033   \n",
       "\n",
       "       Yearly July 1st Estimates  Yearly July 1st Estimates Code  Population  \n",
       "18532                       2010                          2010.0       22653  \n",
       "20169                       2009                          2009.0       28720  \n",
       "17948                       2011                          2011.0      515856  \n",
       "37444                       2007                          2007.0       13429  \n",
       "24046                       2012                          2012.0       51791  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 40495 entries, 0 to 40936\n",
      "Data columns (total 7 columns):\n",
      " #   Column                          Non-Null Count  Dtype  \n",
      "---  ------                          --------------  -----  \n",
      " 0   State                           40495 non-null  object \n",
      " 1   State Code                      40495 non-null  object \n",
      " 2   County                          40495 non-null  object \n",
      " 3   County Code                     40495 non-null  object \n",
      " 4   Yearly July 1st Estimates       40495 non-null  int64  \n",
      " 5   Yearly July 1st Estimates Code  40495 non-null  float64\n",
      " 6   Population                      40495 non-null  int64  \n",
      "dtypes: float64(1), int64(2), object(4)\n",
      "memory usage: 2.5+ MB\n"
     ]
    }
   ],
   "source": [
    "df2.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "df3 = df2.copy()\n",
    "\n",
    "# rename columns\n",
    "df3 = df3.rename(\n",
    "    columns={\n",
    "        \"Yearly July 1st Estimates\": \"Year\",\n",
    "        \"State Code\": \"State_Code\",\n",
    "        \"County Code\": \"County_Code\",\n",
    "    }\n",
    ")\n",
    "\n",
    "# reorder columns\n",
    "df3 = df3[\n",
    "    [\n",
    "        \"State\",\n",
    "        \"State_Code\",\n",
    "        \"County\",\n",
    "        \"County_Code\",\n",
    "        \"Year\",\n",
    "        \"Population\",\n",
    "    ]\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State_Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County_Code</th>\n",
       "      <th>Year</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>19741</th>\n",
       "      <td>Missouri</td>\n",
       "      <td>29</td>\n",
       "      <td>Daviess County, MO</td>\n",
       "      <td>29061</td>\n",
       "      <td>2010</td>\n",
       "      <td>8444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27063</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>39</td>\n",
       "      <td>Harrison County, OH</td>\n",
       "      <td>39067</td>\n",
       "      <td>2013</td>\n",
       "      <td>15598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>646</th>\n",
       "      <td>Alabama</td>\n",
       "      <td>01</td>\n",
       "      <td>Monroe County, AL</td>\n",
       "      <td>01099</td>\n",
       "      <td>2012</td>\n",
       "      <td>22582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15374</th>\n",
       "      <td>Maine</td>\n",
       "      <td>23</td>\n",
       "      <td>Androscoggin County, ME</td>\n",
       "      <td>23001</td>\n",
       "      <td>2011</td>\n",
       "      <td>107458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1705</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Craighead County, AR</td>\n",
       "      <td>05031</td>\n",
       "      <td>2005</td>\n",
       "      <td>87512</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          State State_Code                   County County_Code  Year  \\\n",
       "19741  Missouri         29       Daviess County, MO       29061  2010   \n",
       "27063      Ohio         39      Harrison County, OH       39067  2013   \n",
       "646     Alabama         01        Monroe County, AL       01099  2012   \n",
       "15374     Maine         23  Androscoggin County, ME       23001  2011   \n",
       "1705   Arkansas         05     Craighead County, AR       05031  2005   \n",
       "\n",
       "       Population  \n",
       "19741        8444  \n",
       "27063       15598  \n",
       "646         22582  \n",
       "15374      107458  \n",
       "1705        87512  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>BUYER_COUNTY</th>\n",
       "      <th>BUYER_STATE</th>\n",
       "      <th>countyfips</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2151</th>\n",
       "      <td>GARVIN</td>\n",
       "      <td>OK</td>\n",
       "      <td>40049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>274</th>\n",
       "      <td>LAKE</td>\n",
       "      <td>CO</td>\n",
       "      <td>8065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>780</th>\n",
       "      <td>WASHINGTON</td>\n",
       "      <td>IN</td>\n",
       "      <td>18175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>485</th>\n",
       "      <td>MONROE</td>\n",
       "      <td>GA</td>\n",
       "      <td>13207</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2114</th>\n",
       "      <td>STARK</td>\n",
       "      <td>OH</td>\n",
       "      <td>39151</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     BUYER_COUNTY BUYER_STATE  countyfips\n",
       "2151       GARVIN          OK       40049\n",
       "274          LAKE          CO        8065\n",
       "780    WASHINGTON          IN       18175\n",
       "485        MONROE          GA       13207\n",
       "2114        STARK          OH       39151"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# maps with fips for proper county names\n",
    "fips = pd.read_csv(\"../.01_Data/01_Raw/county_fips.csv\")\n",
    "fips.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# padding fips to have consistency\n",
    "fips[\"countyfips\"] = fips[\"countyfips\"].astype(str).str.zfill(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "# performing left join to get the county names\n",
    "df4 = pd.merge(\n",
    "    df3,\n",
    "    fips,\n",
    "    how=\"left\",\n",
    "    left_on=\"County_Code\",\n",
    "    right_on=\"countyfips\",\n",
    "    validate=\"m:1\",\n",
    "    indicator=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "_merge\n",
       "both          40456\n",
       "left_only        39\n",
       "right_only        0\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# validate match for all rows\n",
    "df4[\"_merge\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State_Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County_Code</th>\n",
       "      <th>Year</th>\n",
       "      <th>Population</th>\n",
       "      <th>BUYER_COUNTY</th>\n",
       "      <th>BUYER_STATE</th>\n",
       "      <th>countyfips</th>\n",
       "      <th>_merge</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1690</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2003</td>\n",
       "      <td>9239</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1691</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2004</td>\n",
       "      <td>9334</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1692</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2005</td>\n",
       "      <td>9358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1693</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2006</td>\n",
       "      <td>9437</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1694</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2007</td>\n",
       "      <td>9478</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1695</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2008</td>\n",
       "      <td>9573</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1696</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2009</td>\n",
       "      <td>9490</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1697</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2010</td>\n",
       "      <td>9515</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1698</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2011</td>\n",
       "      <td>9404</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1699</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2012</td>\n",
       "      <td>9344</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1700</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2013</td>\n",
       "      <td>9254</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1701</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2014</td>\n",
       "      <td>9163</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1702</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Montgomery County, AR</td>\n",
       "      <td>05097</td>\n",
       "      <td>2015</td>\n",
       "      <td>9029</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6747</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2003</td>\n",
       "      <td>127</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6748</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2004</td>\n",
       "      <td>117</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6749</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2005</td>\n",
       "      <td>114</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6750</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2006</td>\n",
       "      <td>109</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6751</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2007</td>\n",
       "      <td>105</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6752</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2008</td>\n",
       "      <td>99</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6753</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2009</td>\n",
       "      <td>93</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6754</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2010</td>\n",
       "      <td>90</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6755</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2011</td>\n",
       "      <td>90</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6756</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2012</td>\n",
       "      <td>89</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6757</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2013</td>\n",
       "      <td>89</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6758</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2014</td>\n",
       "      <td>89</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6759</th>\n",
       "      <td>Hawaii</td>\n",
       "      <td>15</td>\n",
       "      <td>Kalawao County, HI</td>\n",
       "      <td>15005</td>\n",
       "      <td>2015</td>\n",
       "      <td>88</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30979</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2003</td>\n",
       "      <td>12993</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30980</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2004</td>\n",
       "      <td>12983</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30981</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2005</td>\n",
       "      <td>13150</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30982</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2006</td>\n",
       "      <td>13404</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30983</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2007</td>\n",
       "      <td>13345</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30984</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2008</td>\n",
       "      <td>13368</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30985</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2009</td>\n",
       "      <td>13425</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30986</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2010</td>\n",
       "      <td>13636</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30987</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2011</td>\n",
       "      <td>13897</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30988</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2012</td>\n",
       "      <td>14041</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30989</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2013</td>\n",
       "      <td>14130</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30990</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2014</td>\n",
       "      <td>14217</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30991</th>\n",
       "      <td>South Dakota</td>\n",
       "      <td>46</td>\n",
       "      <td>Oglala Lakota County, SD</td>\n",
       "      <td>46102</td>\n",
       "      <td>2015</td>\n",
       "      <td>14364</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              State State_Code                    County County_Code  Year  \\\n",
       "1690       Arkansas         05     Montgomery County, AR       05097  2003   \n",
       "1691       Arkansas         05     Montgomery County, AR       05097  2004   \n",
       "1692       Arkansas         05     Montgomery County, AR       05097  2005   \n",
       "1693       Arkansas         05     Montgomery County, AR       05097  2006   \n",
       "1694       Arkansas         05     Montgomery County, AR       05097  2007   \n",
       "1695       Arkansas         05     Montgomery County, AR       05097  2008   \n",
       "1696       Arkansas         05     Montgomery County, AR       05097  2009   \n",
       "1697       Arkansas         05     Montgomery County, AR       05097  2010   \n",
       "1698       Arkansas         05     Montgomery County, AR       05097  2011   \n",
       "1699       Arkansas         05     Montgomery County, AR       05097  2012   \n",
       "1700       Arkansas         05     Montgomery County, AR       05097  2013   \n",
       "1701       Arkansas         05     Montgomery County, AR       05097  2014   \n",
       "1702       Arkansas         05     Montgomery County, AR       05097  2015   \n",
       "6747         Hawaii         15        Kalawao County, HI       15005  2003   \n",
       "6748         Hawaii         15        Kalawao County, HI       15005  2004   \n",
       "6749         Hawaii         15        Kalawao County, HI       15005  2005   \n",
       "6750         Hawaii         15        Kalawao County, HI       15005  2006   \n",
       "6751         Hawaii         15        Kalawao County, HI       15005  2007   \n",
       "6752         Hawaii         15        Kalawao County, HI       15005  2008   \n",
       "6753         Hawaii         15        Kalawao County, HI       15005  2009   \n",
       "6754         Hawaii         15        Kalawao County, HI       15005  2010   \n",
       "6755         Hawaii         15        Kalawao County, HI       15005  2011   \n",
       "6756         Hawaii         15        Kalawao County, HI       15005  2012   \n",
       "6757         Hawaii         15        Kalawao County, HI       15005  2013   \n",
       "6758         Hawaii         15        Kalawao County, HI       15005  2014   \n",
       "6759         Hawaii         15        Kalawao County, HI       15005  2015   \n",
       "30979  South Dakota         46  Oglala Lakota County, SD       46102  2003   \n",
       "30980  South Dakota         46  Oglala Lakota County, SD       46102  2004   \n",
       "30981  South Dakota         46  Oglala Lakota County, SD       46102  2005   \n",
       "30982  South Dakota         46  Oglala Lakota County, SD       46102  2006   \n",
       "30983  South Dakota         46  Oglala Lakota County, SD       46102  2007   \n",
       "30984  South Dakota         46  Oglala Lakota County, SD       46102  2008   \n",
       "30985  South Dakota         46  Oglala Lakota County, SD       46102  2009   \n",
       "30986  South Dakota         46  Oglala Lakota County, SD       46102  2010   \n",
       "30987  South Dakota         46  Oglala Lakota County, SD       46102  2011   \n",
       "30988  South Dakota         46  Oglala Lakota County, SD       46102  2012   \n",
       "30989  South Dakota         46  Oglala Lakota County, SD       46102  2013   \n",
       "30990  South Dakota         46  Oglala Lakota County, SD       46102  2014   \n",
       "30991  South Dakota         46  Oglala Lakota County, SD       46102  2015   \n",
       "\n",
       "       Population BUYER_COUNTY BUYER_STATE countyfips     _merge  \n",
       "1690         9239          NaN         NaN        NaN  left_only  \n",
       "1691         9334          NaN         NaN        NaN  left_only  \n",
       "1692         9358          NaN         NaN        NaN  left_only  \n",
       "1693         9437          NaN         NaN        NaN  left_only  \n",
       "1694         9478          NaN         NaN        NaN  left_only  \n",
       "1695         9573          NaN         NaN        NaN  left_only  \n",
       "1696         9490          NaN         NaN        NaN  left_only  \n",
       "1697         9515          NaN         NaN        NaN  left_only  \n",
       "1698         9404          NaN         NaN        NaN  left_only  \n",
       "1699         9344          NaN         NaN        NaN  left_only  \n",
       "1700         9254          NaN         NaN        NaN  left_only  \n",
       "1701         9163          NaN         NaN        NaN  left_only  \n",
       "1702         9029          NaN         NaN        NaN  left_only  \n",
       "6747          127          NaN         NaN        NaN  left_only  \n",
       "6748          117          NaN         NaN        NaN  left_only  \n",
       "6749          114          NaN         NaN        NaN  left_only  \n",
       "6750          109          NaN         NaN        NaN  left_only  \n",
       "6751          105          NaN         NaN        NaN  left_only  \n",
       "6752           99          NaN         NaN        NaN  left_only  \n",
       "6753           93          NaN         NaN        NaN  left_only  \n",
       "6754           90          NaN         NaN        NaN  left_only  \n",
       "6755           90          NaN         NaN        NaN  left_only  \n",
       "6756           89          NaN         NaN        NaN  left_only  \n",
       "6757           89          NaN         NaN        NaN  left_only  \n",
       "6758           89          NaN         NaN        NaN  left_only  \n",
       "6759           88          NaN         NaN        NaN  left_only  \n",
       "30979       12993          NaN         NaN        NaN  left_only  \n",
       "30980       12983          NaN         NaN        NaN  left_only  \n",
       "30981       13150          NaN         NaN        NaN  left_only  \n",
       "30982       13404          NaN         NaN        NaN  left_only  \n",
       "30983       13345          NaN         NaN        NaN  left_only  \n",
       "30984       13368          NaN         NaN        NaN  left_only  \n",
       "30985       13425          NaN         NaN        NaN  left_only  \n",
       "30986       13636          NaN         NaN        NaN  left_only  \n",
       "30987       13897          NaN         NaN        NaN  left_only  \n",
       "30988       14041          NaN         NaN        NaN  left_only  \n",
       "30989       14130          NaN         NaN        NaN  left_only  \n",
       "30990       14217          NaN         NaN        NaN  left_only  \n",
       "30991       14364          NaN         NaN        NaN  left_only  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Check for unmatched rows\n",
    "df4[(df4[\"_merge\"] == \"left_only\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Montgomery County, AR', 'Kalawao County, HI',\n",
       "       'Oglala Lakota County, SD'], dtype=object)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df4[(df4[\"_merge\"] == \"left_only\")][\"County\"].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Manual Correction\n",
    "df4.loc[df4[\"County\"] == \"Montgomery County, AR\", \"BUYER_COUNTY\"] = \"MONTGOMERY\"\n",
    "df4.loc[df4[\"County\"] == \"Kalawao County, HI\", \"BUYER_COUNTY\"] = \"KALAWAO\"\n",
    "df4.loc[df4[\"County\"] == \"Oglala Lakota County, SD\", \"BUYER_COUNTY\"] = \"OGLALA LAKOTA\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State_Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County_Code</th>\n",
       "      <th>Year</th>\n",
       "      <th>Population</th>\n",
       "      <th>BUYER_COUNTY</th>\n",
       "      <th>BUYER_STATE</th>\n",
       "      <th>countyfips</th>\n",
       "      <th>_merge</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>27865</th>\n",
       "      <td>Oklahoma</td>\n",
       "      <td>40</td>\n",
       "      <td>Logan County, OK</td>\n",
       "      <td>40083</td>\n",
       "      <td>2009</td>\n",
       "      <td>41116</td>\n",
       "      <td>LOGAN</td>\n",
       "      <td>OK</td>\n",
       "      <td>40083</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38717</th>\n",
       "      <td>West Virginia</td>\n",
       "      <td>54</td>\n",
       "      <td>Hampshire County, WV</td>\n",
       "      <td>54027</td>\n",
       "      <td>2006</td>\n",
       "      <td>23016</td>\n",
       "      <td>HAMPSHIRE</td>\n",
       "      <td>WV</td>\n",
       "      <td>54027</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1637</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>05</td>\n",
       "      <td>Madison County, AR</td>\n",
       "      <td>05087</td>\n",
       "      <td>2015</td>\n",
       "      <td>15719</td>\n",
       "      <td>MADISON</td>\n",
       "      <td>AR</td>\n",
       "      <td>05087</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28355</th>\n",
       "      <td>Oregon</td>\n",
       "      <td>41</td>\n",
       "      <td>Clackamas County, OR</td>\n",
       "      <td>41005</td>\n",
       "      <td>2005</td>\n",
       "      <td>359308</td>\n",
       "      <td>CLACKAMAS</td>\n",
       "      <td>OR</td>\n",
       "      <td>41005</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34988</th>\n",
       "      <td>Texas</td>\n",
       "      <td>48</td>\n",
       "      <td>Robertson County, TX</td>\n",
       "      <td>48395</td>\n",
       "      <td>2008</td>\n",
       "      <td>16535</td>\n",
       "      <td>ROBERTSON</td>\n",
       "      <td>TX</td>\n",
       "      <td>48395</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               State State_Code                County County_Code  Year  \\\n",
       "27865       Oklahoma         40      Logan County, OK       40083  2009   \n",
       "38717  West Virginia         54  Hampshire County, WV       54027  2006   \n",
       "1637        Arkansas         05    Madison County, AR       05087  2015   \n",
       "28355         Oregon         41  Clackamas County, OR       41005  2005   \n",
       "34988          Texas         48  Robertson County, TX       48395  2008   \n",
       "\n",
       "       Population BUYER_COUNTY BUYER_STATE countyfips _merge  \n",
       "27865       41116        LOGAN          OK      40083   both  \n",
       "38717       23016    HAMPSHIRE          WV      54027   both  \n",
       "1637        15719      MADISON          AR      05087   both  \n",
       "28355      359308    CLACKAMAS          OR      41005   both  \n",
       "34988       16535    ROBERTSON          TX      48395   both  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df4.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 40495 entries, 0 to 40494\n",
      "Data columns (total 10 columns):\n",
      " #   Column        Non-Null Count  Dtype   \n",
      "---  ------        --------------  -----   \n",
      " 0   State         40495 non-null  object  \n",
      " 1   State_Code    40495 non-null  object  \n",
      " 2   County        40495 non-null  object  \n",
      " 3   County_Code   40495 non-null  object  \n",
      " 4   Year          40495 non-null  int64   \n",
      " 5   Population    40495 non-null  int64   \n",
      " 6   BUYER_COUNTY  40495 non-null  object  \n",
      " 7   BUYER_STATE   40456 non-null  object  \n",
      " 8   countyfips    40456 non-null  object  \n",
      " 9   _merge        40495 non-null  category\n",
      "dtypes: category(1), int64(2), object(7)\n",
      "memory usage: 2.8+ MB\n"
     ]
    }
   ],
   "source": [
    "# Final Verification\n",
    "df4.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>state</th>\n",
       "      <th>abbrev</th>\n",
       "      <th>code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>Ark.</td>\n",
       "      <td>AR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Georgia</td>\n",
       "      <td>Ga.</td>\n",
       "      <td>GA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>Rhode Island</td>\n",
       "      <td>R.I.</td>\n",
       "      <td>RI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>Ohio</td>\n",
       "      <td>OH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>Texas</td>\n",
       "      <td>Tex.</td>\n",
       "      <td>TX</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           state abbrev code\n",
       "3       Arkansas   Ark.   AR\n",
       "10       Georgia    Ga.   GA\n",
       "39  Rhode Island   R.I.   RI\n",
       "35          Ohio   Ohio   OH\n",
       "43         Texas   Tex.   TX"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "abbreviations = pd.read_csv(\"../.01_Data/01_Raw/state_abbreviations.csv\")\n",
    "abbreviations.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# rename colums to match with the main dataframe\n",
    "abbreviations = abbreviations.rename(\n",
    "    columns={\n",
    "        \"state\": \"State\",\n",
    "        \"code\": \"State_Code\",\n",
    "    }\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>BUYER_COUNTY</th>\n",
       "      <th>County_Code</th>\n",
       "      <th>Year</th>\n",
       "      <th>Population</th>\n",
       "      <th>State_Code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>32238</th>\n",
       "      <td>Tennessee</td>\n",
       "      <td>STEWART</td>\n",
       "      <td>47161</td>\n",
       "      <td>2014</td>\n",
       "      <td>13211</td>\n",
       "      <td>TN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2461</th>\n",
       "      <td>California</td>\n",
       "      <td>RIVERSIDE</td>\n",
       "      <td>06065</td>\n",
       "      <td>2007</td>\n",
       "      <td>2075183</td>\n",
       "      <td>CA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36672</th>\n",
       "      <td>Virginia</td>\n",
       "      <td>FAUQUIER</td>\n",
       "      <td>51061</td>\n",
       "      <td>2015</td>\n",
       "      <td>68449</td>\n",
       "      <td>VA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1370</th>\n",
       "      <td>Arkansas</td>\n",
       "      <td>FRANKLIN</td>\n",
       "      <td>05047</td>\n",
       "      <td>2008</td>\n",
       "      <td>18229</td>\n",
       "      <td>AR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2130</th>\n",
       "      <td>California</td>\n",
       "      <td>CONTRA COSTA</td>\n",
       "      <td>06013</td>\n",
       "      <td>2014</td>\n",
       "      <td>1108665</td>\n",
       "      <td>CA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            State  BUYER_COUNTY County_Code  Year  Population State_Code\n",
       "32238   Tennessee       STEWART       47161  2014       13211         TN\n",
       "2461   California     RIVERSIDE       06065  2007     2075183         CA\n",
       "36672    Virginia      FAUQUIER       51061  2015       68449         VA\n",
       "1370     Arkansas      FRANKLIN       05047  2008       18229         AR\n",
       "2130   California  CONTRA COSTA       06013  2014     1108665         CA"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# select required columns\n",
    "df5 = pd.merge(\n",
    "    df4[[\"State\", \"BUYER_COUNTY\", \"County_Code\", \"Year\", \"Population\"]],\n",
    "    abbreviations[[\"State\", \"State_Code\"]],\n",
    "    how=\"left\",\n",
    "    left_on=\"State\",\n",
    "    right_on=\"State\",\n",
    "    validate=\"m:1\",\n",
    ")\n",
    "df5.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>State</th>\n",
       "      <th>State_Code</th>\n",
       "      <th>County</th>\n",
       "      <th>County_Code</th>\n",
       "      <th>Year</th>\n",
       "      <th>Population</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>34793</th>\n",
       "      <td>Texas</td>\n",
       "      <td>TX</td>\n",
       "      <td>PANOLA</td>\n",
       "      <td>48365</td>\n",
       "      <td>2008</td>\n",
       "      <td>23537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37853</th>\n",
       "      <td>Virginia</td>\n",
       "      <td>VA</td>\n",
       "      <td>NORFOLK CITY</td>\n",
       "      <td>51710</td>\n",
       "      <td>2013</td>\n",
       "      <td>245598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2350</th>\n",
       "      <td>California</td>\n",
       "      <td>CA</td>\n",
       "      <td>MERCED</td>\n",
       "      <td>06047</td>\n",
       "      <td>2013</td>\n",
       "      <td>261888</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13345</th>\n",
       "      <td>Kentucky</td>\n",
       "      <td>KY</td>\n",
       "      <td>LAUREL</td>\n",
       "      <td>21125</td>\n",
       "      <td>2010</td>\n",
       "      <td>58993</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28032</th>\n",
       "      <td>Oklahoma</td>\n",
       "      <td>OK</td>\n",
       "      <td>OKLAHOMA</td>\n",
       "      <td>40109</td>\n",
       "      <td>2007</td>\n",
       "      <td>695706</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            State State_Code        County County_Code  Year  Population\n",
       "34793       Texas         TX        PANOLA       48365  2008       23537\n",
       "37853    Virginia         VA  NORFOLK CITY       51710  2013      245598\n",
       "2350   California         CA        MERCED       06047  2013      261888\n",
       "13345    Kentucky         KY        LAUREL       21125  2010       58993\n",
       "28032    Oklahoma         OK      OKLAHOMA       40109  2007      695706"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# rename columns\n",
    "df5 = df5.rename(\n",
    "    columns={\n",
    "        \"BUYER_COUNTY\": \"County\",\n",
    "    }\n",
    ")\n",
    "\n",
    "# reorder columns\n",
    "df5 = df5[\n",
    "    [\n",
    "        \"State\",\n",
    "        \"State_Code\",\n",
    "        \"County\",\n",
    "        \"County_Code\",\n",
    "        \"Year\",\n",
    "        \"Population\",\n",
    "    ]\n",
    "]\n",
    "\n",
    "df5.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 40495 entries, 0 to 40494\n",
      "Data columns (total 6 columns):\n",
      " #   Column       Non-Null Count  Dtype \n",
      "---  ------       --------------  ----- \n",
      " 0   State        40495 non-null  object\n",
      " 1   State_Code   40495 non-null  object\n",
      " 2   County       40495 non-null  object\n",
      " 3   County_Code  40495 non-null  object\n",
      " 4   Year         40495 non-null  int64 \n",
      " 5   Population   40495 non-null  int64 \n",
      "dtypes: int64(2), object(4)\n",
      "memory usage: 1.9+ MB\n"
     ]
    }
   ],
   "source": [
    "df5.info()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}