import pandas as pd
df = pd.DataFrame([{'Name': 'Chris', 'Item Purchased': 'Sponge', 'Cost': 22.50},
{'Name': 'Kevyn', 'Item Purchased': 'Kitty Litter', 'Cost': 2.50},
{'Name': 'Filip', 'Item Purchased': 'Spoon', 'Cost': 5.00}],
index=['Store 1', 'Store 1', 'Store 2'])
df
Cost | Item Purchased | Name | |
---|---|---|---|
Store 1 | 22.5 | Sponge | Chris |
Store 1 | 2.5 | Kitty Litter | Kevyn |
Store 2 | 5.0 | Spoon | Filip |
df['Date'] = ['December 1', 'January 1', 'mid-May']
df
Cost | Item Purchased | Name | Date | |
---|---|---|---|---|
Store 1 | 22.5 | Sponge | Chris | December 1 |
Store 1 | 2.5 | Kitty Litter | Kevyn | January 1 |
Store 2 | 5.0 | Spoon | Filip | mid-May |
df['Delivered'] = True
df
Cost | Item Purchased | Name | Date | Delivered | |
---|---|---|---|---|---|
Store 1 | 22.5 | Sponge | Chris | December 1 | True |
Store 1 | 2.5 | Kitty Litter | Kevyn | January 1 | True |
Store 2 | 5.0 | Spoon | Filip | mid-May | True |
df['Feedback'] = ['Positive', None, 'Negative']
df
Cost | Item Purchased | Name | Date | Delivered | Feedback | |
---|---|---|---|---|---|---|
Store 1 | 22.5 | Sponge | Chris | December 1 | True | Positive |
Store 1 | 2.5 | Kitty Litter | Kevyn | January 1 | True | None |
Store 2 | 5.0 | Spoon | Filip | mid-May | True | Negative |
adf = df.reset_index()
adf['Date'] = pd.Series({0: 'December 1', 2: 'mid-May'})
adf
staff_df = pd.DataFrame([{'Name': 'Kelly', 'Role': 'Director of HR'},
{'Name': 'Sally', 'Role': 'Course liasion'},
{'Name': 'James', 'Role': 'Grader'}])
staff_df = staff_df.set_index('Name')
student_df = pd.DataFrame([{'Name': 'James', 'School': 'Business'},
{'Name': 'Mike', 'School': 'Law'},
{'Name': 'Sally', 'School': 'Engineering'}])
student_df = student_df.set_index('Name')
print(staff_df)
print()
print(student_df)
Role Name Kelly Director of HR Sally Course liasion James Grader School Name James Business Mike Law Sally Engineering
pd.merge?
pd.merge(staff_df, student_df, how='outer', left_index=True, right_index=True)
Role | School | |
---|---|---|
Name | ||
James | Grader | Business |
Kelly | Director of HR | NaN |
Mike | NaN | Law |
Sally | Course liasion | Engineering |
pd.merge(staff_df, student_df, how='inner', left_index=True, right_index=True)
Role | School | |
---|---|---|
Name | ||
Sally | Course liasion | Engineering |
James | Grader | Business |
pd.merge(staff_df, student_df, how='left', left_index=True, right_index=True)
Role | School | |
---|---|---|
Name | ||
Kelly | Director of HR | NaN |
Sally | Course liasion | Engineering |
James | Grader | Business |
pd.merge(staff_df, student_df, how='right', left_index=True, right_index=True)
Role | School | |
---|---|---|
Name | ||
James | Grader | Business |
Mike | NaN | Law |
Sally | Course liasion | Engineering |
staff_df = staff_df.reset_index()
student_df = student_df.reset_index()
pd.merge(staff_df, student_df, how='left', left_on='Name', right_on='Name')
staff_df = pd.DataFrame([{'Name': 'Kelly', 'Role': 'Director of HR', 'Location': 'State Street'},
{'Name': 'Sally', 'Role': 'Course liasion', 'Location': 'Washington Avenue'},
{'Name': 'James', 'Role': 'Grader', 'Location': 'Washington Avenue'}])
student_df = pd.DataFrame([{'Name': 'James', 'School': 'Business', 'Location': '1024 Billiard Avenue'},
{'Name': 'Mike', 'School': 'Law', 'Location': 'Fraternity House #22'},
{'Name': 'Sally', 'School': 'Engineering', 'Location': '512 Wilson Crescent'}])
pd.merge(staff_df, student_df, how='left', left_on='Name', right_on='Name')
staff_df = pd.DataFrame([{'First Name': 'Kelly', 'Last Name': 'Desjardins', 'Role': 'Director of HR'},
{'First Name': 'Sally', 'Last Name': 'Brooks', 'Role': 'Course liasion'},
{'First Name': 'James', 'Last Name': 'Wilde', 'Role': 'Grader'}])
student_df = pd.DataFrame([{'First Name': 'James', 'Last Name': 'Hammond', 'School': 'Business'},
{'First Name': 'Mike', 'Last Name': 'Smith', 'School': 'Law'},
{'First Name': 'Sally', 'Last Name': 'Brooks', 'School': 'Engineering'}])
staff_df
student_df
pd.merge(staff_df, student_df, how='inner', left_on=['First Name','Last Name'], right_on=['First Name','Last Name'])
import pandas as pd
df = pd.read_csv('~/Data_Science_with_Python/course1_downloads/census.csv')
df
SUMLEV | REGION | DIVISION | STATE | COUNTY | STNAME | CTYNAME | CENSUS2010POP | ESTIMATESBASE2010 | POPESTIMATE2010 | ... | RDOMESTICMIG2011 | RDOMESTICMIG2012 | RDOMESTICMIG2013 | RDOMESTICMIG2014 | RDOMESTICMIG2015 | RNETMIG2011 | RNETMIG2012 | RNETMIG2013 | RNETMIG2014 | RNETMIG2015 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 40 | 3 | 6 | 1 | 0 | Alabama | Alabama | 4779736 | 4780127 | 4785161 | ... | 0.002295 | -0.193196 | 0.381066 | 0.582002 | -0.467369 | 1.030015 | 0.826644 | 1.383282 | 1.724718 | 0.712594 |
1 | 50 | 3 | 6 | 1 | 1 | Alabama | Autauga County | 54571 | 54571 | 54660 | ... | 7.242091 | -2.915927 | -3.012349 | 2.265971 | -2.530799 | 7.606016 | -2.626146 | -2.722002 | 2.592270 | -2.187333 |
2 | 50 | 3 | 6 | 1 | 3 | Alabama | Baldwin County | 182265 | 182265 | 183193 | ... | 14.832960 | 17.647293 | 21.845705 | 19.243287 | 17.197872 | 15.844176 | 18.559627 | 22.727626 | 20.317142 | 18.293499 |
3 | 50 | 3 | 6 | 1 | 5 | Alabama | Barbour County | 27457 | 27457 | 27341 | ... | -4.728132 | -2.500690 | -7.056824 | -3.904217 | -10.543299 | -4.874741 | -2.758113 | -7.167664 | -3.978583 | -10.543299 |
4 | 50 | 3 | 6 | 1 | 7 | Alabama | Bibb County | 22915 | 22919 | 22861 | ... | -5.527043 | -5.068871 | -6.201001 | -0.177537 | 0.177258 | -5.088389 | -4.363636 | -5.403729 | 0.754533 | 1.107861 |
5 | 50 | 3 | 6 | 1 | 9 | Alabama | Blount County | 57322 | 57322 | 57373 | ... | 1.807375 | -1.177622 | -1.748766 | -2.062535 | -1.369970 | 1.859511 | -0.848580 | -1.402476 | -1.577232 | -0.884411 |
6 | 50 | 3 | 6 | 1 | 11 | Alabama | Bullock County | 10914 | 10915 | 10887 | ... | -30.953709 | -5.180127 | -1.130263 | 14.354290 | -16.167247 | -29.001673 | -2.825524 | 1.507017 | 17.243790 | -13.193961 |
7 | 50 | 3 | 6 | 1 | 13 | Alabama | Butler County | 20947 | 20946 | 20944 | ... | -14.032727 | -11.684234 | -5.655413 | 1.085428 | -6.529805 | -13.936612 | -11.586865 | -5.557058 | 1.184103 | -6.430868 |
8 | 50 | 3 | 6 | 1 | 15 | Alabama | Calhoun County | 118572 | 118586 | 118437 | ... | -6.155670 | -4.611706 | -5.524649 | -4.463211 | -3.376322 | -5.791579 | -4.092677 | -5.062836 | -3.912834 | -2.806406 |
9 | 50 | 3 | 6 | 1 | 17 | Alabama | Chambers County | 34215 | 34170 | 34098 | ... | -2.731639 | 3.849092 | 2.872721 | -2.287222 | 1.349468 | -1.821092 | 4.701181 | 3.781439 | -1.290228 | 2.346901 |
10 | 50 | 3 | 6 | 1 | 19 | Alabama | Cherokee County | 25989 | 25986 | 25976 | ... | 6.339327 | 1.113180 | 5.488706 | -0.076806 | -3.239866 | 6.416167 | 1.420264 | 5.757384 | 0.230419 | -2.931307 |
11 | 50 | 3 | 6 | 1 | 21 | Alabama | Chilton County | 43643 | 43631 | 43665 | ... | -1.372935 | -2.653369 | 0.480044 | 0.456017 | -2.253483 | -0.823761 | -2.447504 | 0.868651 | 0.957636 | -1.752709 |
12 | 50 | 3 | 6 | 1 | 23 | Alabama | Choctaw County | 13859 | 13858 | 13841 | ... | -15.455274 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | -15.528177 | -0.737028 | -8.766391 | -1.274984 | -5.291205 |
13 | 50 | 3 | 6 | 1 | 25 | Alabama | Clarke County | 25833 | 25840 | 25767 | ... | -6.194363 | -17.667705 | -0.318345 | -8.686428 | -5.613667 | -6.077488 | -17.509958 | -0.159172 | -8.486280 | -5.411736 |
14 | 50 | 3 | 6 | 1 | 27 | Alabama | Clay County | 13932 | 13932 | 13880 | ... | -10.744102 | -13.345130 | 4.902871 | 5.702648 | 3.912450 | -10.816697 | -13.345130 | 4.977157 | 5.776708 | 3.986270 |
15 | 50 | 3 | 6 | 1 | 29 | Alabama | Cleburne County | 14972 | 14972 | 14973 | ... | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 |
16 | 50 | 3 | 6 | 1 | 31 | Alabama | Coffee County | 49948 | 49948 | 50177 | ... | 0.377640 | 7.675579 | -13.146535 | -3.602859 | 2.214774 | 2.166460 | 11.513368 | -10.438741 | -0.767822 | 5.350738 |
17 | 50 | 3 | 6 | 1 | 33 | Alabama | Colbert County | 54428 | 54428 | 54514 | ... | -0.073423 | 1.065051 | 1.762390 | 1.835688 | -0.110260 | 0.513964 | 1.469035 | 2.276420 | 2.533249 | 0.588052 |
18 | 50 | 3 | 6 | 1 | 35 | Alabama | Conecuh County | 13228 | 13228 | 13208 | ... | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 |
19 | 50 | 3 | 6 | 1 | 37 | Alabama | Coosa County | 11539 | 11758 | 11758 | ... | -33.930581 | -10.291443 | -4.313831 | -22.958017 | -5.387581 | -34.017138 | -10.380162 | -4.403703 | -23.049483 | -5.387581 |
20 | 50 | 3 | 6 | 1 | 39 | Alabama | Covington County | 37765 | 37765 | 37796 | ... | 6.696899 | -4.612668 | 0.740271 | 3.697932 | -0.316945 | 6.881460 | -4.559952 | 0.793147 | 3.750759 | -0.264121 |
21 | 50 | 3 | 6 | 1 | 41 | Alabama | Crenshaw County | 13906 | 13906 | 13853 | ... | 1.729792 | 3.950156 | -1.864936 | 3.084648 | 3.439504 | 2.666763 | 5.099293 | -0.502098 | 4.734577 | 5.087600 |
22 | 50 | 3 | 6 | 1 | 43 | Alabama | Cullman County | 80406 | 80410 | 80473 | ... | -1.404233 | -1.019628 | 4.071247 | 5.087142 | 7.915406 | -1.031427 | -0.634159 | 4.542916 | 5.593387 | 8.417777 |
23 | 50 | 3 | 6 | 1 | 45 | Alabama | Dale County | 50251 | 50251 | 50358 | ... | -10.749798 | -5.277150 | -15.236079 | -11.979785 | -5.107706 | -9.575283 | -0.776637 | -12.640155 | -9.503292 | -1.998668 |
24 | 50 | 3 | 6 | 1 | 47 | Alabama | Dallas County | 43820 | 43820 | 43803 | ... | -15.635599 | -11.308243 | -16.745678 | -9.344789 | -14.687232 | -15.727573 | -11.378047 | -16.792849 | -9.368689 | -14.711389 |
25 | 50 | 3 | 6 | 1 | 49 | Alabama | DeKalb County | 71109 | 71115 | 71142 | ... | 0.294677 | -9.302391 | -1.748807 | 0.267830 | 0.028141 | 1.375159 | -8.656001 | -1.029539 | 1.198187 | 0.956790 |
26 | 50 | 3 | 6 | 1 | 51 | Alabama | Elmore County | 79303 | 79296 | 79465 | ... | 3.235576 | 0.822717 | 1.760531 | -1.507057 | 2.067820 | 3.674511 | 1.558176 | 2.306047 | -0.951175 | 2.757093 |
27 | 50 | 3 | 6 | 1 | 53 | Alabama | Escambia County | 38319 | 38319 | 38309 | ... | -3.449988 | -3.855889 | -4.822706 | -1.189831 | 1.190902 | -3.397716 | -3.803428 | -4.769999 | -1.136950 | 1.243830 |
28 | 50 | 3 | 6 | 1 | 55 | Alabama | Etowah County | 104430 | 104427 | 104442 | ... | -1.015919 | 2.062637 | -1.931884 | -1.726932 | -2.082234 | -0.632554 | 2.446383 | -1.518596 | -1.234901 | -1.588308 |
29 | 50 | 3 | 6 | 1 | 57 | Alabama | Fayette County | 17241 | 17241 | 17231 | ... | -5.015601 | -0.646640 | -3.725937 | 0.296745 | -2.797536 | -5.132243 | -0.705426 | -3.785079 | 0.237396 | -2.857058 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
3163 | 50 | 2 | 3 | 55 | 131 | Wisconsin | Washington County | 131887 | 131885 | 131967 | ... | -0.794876 | 0.785279 | -2.215465 | 1.601149 | -0.434498 | -0.431504 | 1.162817 | -1.763330 | 2.104796 | 0.059931 |
3164 | 50 | 2 | 3 | 55 | 133 | Wisconsin | Waukesha County | 389891 | 389938 | 390076 | ... | -0.765799 | 2.128860 | 0.038132 | 0.760109 | -0.719858 | 0.102448 | 3.180527 | 1.189727 | 2.077633 | 0.593567 |
3165 | 50 | 2 | 3 | 55 | 135 | Wisconsin | Waupaca County | 52410 | 52410 | 52422 | ... | 3.111756 | -2.241873 | 6.292687 | -0.441031 | -0.480617 | 3.359933 | -2.011937 | 6.561277 | -0.134227 | -0.173022 |
3166 | 50 | 2 | 3 | 55 | 137 | Wisconsin | Waushara County | 24496 | 24496 | 24506 | ... | 4.930022 | -2.404973 | -4.097017 | -4.906711 | -4.397793 | 5.174486 | -2.160399 | -3.810226 | -4.535615 | -4.024395 |
3167 | 50 | 2 | 3 | 55 | 139 | Wisconsin | Winnebago County | 166994 | 166994 | 167059 | ... | 0.316712 | 2.889873 | 0.833819 | -2.406192 | -4.557985 | 0.842573 | 3.502335 | 1.531624 | -1.545153 | -3.685304 |
3168 | 50 | 2 | 3 | 55 | 141 | Wisconsin | Wood County | 74749 | 74749 | 74807 | ... | -4.081523 | -5.019090 | -6.901200 | -5.596471 | -3.958322 | -3.733590 | -4.562809 | -6.442917 | -5.040889 | -3.414223 |
3169 | 40 | 4 | 8 | 56 | 0 | Wyoming | Wyoming | 563626 | 563767 | 564516 | ... | -0.381530 | 9.636214 | 4.487115 | -4.788275 | -3.221091 | 0.289680 | 10.694870 | 5.440390 | -3.727831 | -2.091573 |
3170 | 50 | 4 | 8 | 56 | 1 | Wyoming | Albany County | 36299 | 36299 | 36428 | ... | 3.708956 | 2.637812 | -3.544634 | -3.334877 | -9.911169 | 6.736119 | 6.433032 | 0.719587 | 1.429233 | -5.166460 |
3171 | 50 | 4 | 8 | 56 | 3 | Wyoming | Big Horn County | 11668 | 11668 | 11672 | ... | 4.868258 | 2.804930 | 16.815908 | -8.026420 | 5.095861 | 4.868258 | 3.144921 | 17.236306 | -7.608378 | 5.513554 |
3172 | 50 | 4 | 8 | 56 | 5 | Wyoming | Campbell County | 46133 | 46133 | 46244 | ... | -2.843479 | 15.601020 | -5.895711 | -8.550911 | 10.916963 | -2.649606 | 15.558684 | -5.916543 | -8.509402 | 10.978525 |
3173 | 50 | 4 | 8 | 56 | 7 | Wyoming | Carbon County | 15885 | 15885 | 15837 | ... | -7.581980 | -13.081441 | 3.178134 | -2.970641 | -23.300971 | -7.392431 | -12.636926 | 3.623073 | -2.338590 | -22.600668 |
3174 | 50 | 4 | 8 | 56 | 9 | Wyoming | Converse County | 13833 | 13833 | 13826 | ... | -12.847499 | 15.493820 | 19.035533 | -20.550587 | -0.070403 | -12.774915 | 16.502720 | 20.093063 | -19.358233 | 1.126443 |
3175 | 50 | 4 | 8 | 56 | 11 | Wyoming | Crook County | 7083 | 7083 | 7114 | ... | -1.544618 | -4.202564 | 1.397819 | 6.378258 | 18.629317 | -0.982939 | -3.642222 | 2.096729 | 7.071547 | 19.309219 |
3176 | 50 | 4 | 8 | 56 | 13 | Wyoming | Fremont County | 40123 | 40123 | 40222 | ... | 2.747083 | 7.782673 | -4.990688 | -12.331633 | -13.673610 | 3.093562 | 8.027411 | -4.747240 | -12.013555 | -13.352750 |
3177 | 50 | 4 | 8 | 56 | 15 | Wyoming | Goshen County | 13249 | 13247 | 13408 | ... | 14.293649 | 3.961413 | -8.079028 | -7.017803 | -11.899450 | 14.886132 | 4.841727 | -6.903896 | -5.761986 | -10.635133 |
3178 | 50 | 4 | 8 | 56 | 17 | Wyoming | Hot Springs County | 4812 | 4812 | 4813 | ... | 3.322604 | 6.208609 | 3.095336 | -6.017222 | -5.454164 | 5.191569 | 6.001656 | 2.888981 | -6.224712 | -5.663940 |
3179 | 50 | 4 | 8 | 56 | 19 | Wyoming | Johnson County | 8569 | 8569 | 8581 | ... | 4.995063 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | 5.227392 | -4.058912 | -0.812583 | -10.715742 | 0.933652 |
3180 | 50 | 4 | 8 | 56 | 21 | Wyoming | Laramie County | 91738 | 91881 | 92271 | ... | -1.200428 | 15.547274 | 4.787847 | -1.226133 | 0.278940 | -0.973320 | 17.914554 | 6.003143 | -0.207819 | 1.673640 |
3181 | 50 | 4 | 8 | 56 | 23 | Wyoming | Lincoln County | 18106 | 18106 | 18091 | ... | -9.802564 | -11.566801 | 13.564556 | 6.125989 | 1.555544 | -9.691801 | -11.566801 | 13.619696 | 6.234414 | 1.662823 |
3182 | 50 | 4 | 8 | 56 | 25 | Wyoming | Natrona County | 75450 | 75450 | 75472 | ... | 7.189319 | 23.066162 | 24.322042 | -0.958472 | -0.061057 | 7.689674 | 23.749508 | 25.085233 | -0.110593 | 0.793743 |
3183 | 50 | 4 | 8 | 56 | 27 | Wyoming | Niobrara County | 2484 | 2484 | 2492 | ... | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 |
3184 | 50 | 4 | 8 | 56 | 29 | Wyoming | Park County | 28205 | 28205 | 28259 | ... | 4.582951 | 8.057765 | 7.641997 | -9.252437 | -2.878980 | 6.486639 | 11.127389 | 10.877797 | -5.585731 | 0.856839 |
3185 | 50 | 4 | 8 | 56 | 31 | Wyoming | Platte County | 8667 | 8667 | 8678 | ... | 4.373094 | 5.392073 | 2.634593 | 6.055759 | 4.662270 | 4.373094 | 4.933173 | 2.176403 | 5.598720 | 4.207414 |
3186 | 50 | 4 | 8 | 56 | 33 | Wyoming | Sheridan County | 29116 | 29116 | 29146 | ... | 0.958559 | 8.425487 | 4.546373 | 3.678069 | -3.298406 | 2.122524 | 9.342778 | 5.523001 | 4.781489 | -2.198937 |
3187 | 50 | 4 | 8 | 56 | 35 | Wyoming | Sublette County | 10247 | 10247 | 10244 | ... | -23.741784 | 15.272374 | -40.870074 | -16.596273 | -22.870900 | -21.092907 | 16.828794 | -39.211861 | -14.409938 | -20.664059 |
3188 | 50 | 4 | 8 | 56 | 37 | Wyoming | Sweetwater County | 43806 | 43806 | 43593 | ... | 1.072643 | 16.243199 | -5.339774 | -14.252889 | -14.248864 | 1.255221 | 16.243199 | -5.295460 | -14.075283 | -14.070195 |
3189 | 50 | 4 | 8 | 56 | 39 | Wyoming | Teton County | 21294 | 21294 | 21297 | ... | -1.589565 | 0.972695 | 19.525929 | 14.143021 | -0.564849 | 0.654527 | 2.408578 | 21.160658 | 16.308671 | 1.520747 |
3190 | 50 | 4 | 8 | 56 | 41 | Wyoming | Uinta County | 21118 | 21118 | 21102 | ... | -17.755986 | -4.916350 | -6.902954 | -14.215862 | -12.127022 | -18.136812 | -5.536861 | -7.521840 | -14.740608 | -12.606351 |
3191 | 50 | 4 | 8 | 56 | 43 | Wyoming | Washakie County | 8533 | 8533 | 8545 | ... | -11.637475 | -0.827815 | -2.013502 | -17.781491 | 1.682288 | -11.990126 | -1.182592 | -2.250385 | -18.020168 | 1.441961 |
3192 | 50 | 4 | 8 | 56 | 45 | Wyoming | Weston County | 7208 | 7208 | 7181 | ... | -11.752361 | -8.040059 | 12.372583 | 1.533635 | 6.935294 | -12.032179 | -8.040059 | 12.372583 | 1.533635 | 6.935294 |
3193 rows × 100 columns
(df.where(df['SUMLEV']==50)
.dropna()
.set_index(['STNAME','CTYNAME'])
.rename(columns={'ESTIMATESBASE2010': 'Estimates Base 2010'}))
SUMLEV | REGION | DIVISION | STATE | COUNTY | CENSUS2010POP | Estimates Base 2010 | POPESTIMATE2010 | POPESTIMATE2011 | POPESTIMATE2012 | ... | RDOMESTICMIG2011 | RDOMESTICMIG2012 | RDOMESTICMIG2013 | RDOMESTICMIG2014 | RDOMESTICMIG2015 | RNETMIG2011 | RNETMIG2012 | RNETMIG2013 | RNETMIG2014 | RNETMIG2015 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STNAME | CTYNAME | |||||||||||||||||||||
Alabama | Autauga County | 50.0 | 3.0 | 6.0 | 1.0 | 1.0 | 54571.0 | 54571.0 | 54660.0 | 55253.0 | 55175.0 | ... | 7.242091 | -2.915927 | -3.012349 | 2.265971 | -2.530799 | 7.606016 | -2.626146 | -2.722002 | 2.592270 | -2.187333 |
Baldwin County | 50.0 | 3.0 | 6.0 | 1.0 | 3.0 | 182265.0 | 182265.0 | 183193.0 | 186659.0 | 190396.0 | ... | 14.832960 | 17.647293 | 21.845705 | 19.243287 | 17.197872 | 15.844176 | 18.559627 | 22.727626 | 20.317142 | 18.293499 | |
Barbour County | 50.0 | 3.0 | 6.0 | 1.0 | 5.0 | 27457.0 | 27457.0 | 27341.0 | 27226.0 | 27159.0 | ... | -4.728132 | -2.500690 | -7.056824 | -3.904217 | -10.543299 | -4.874741 | -2.758113 | -7.167664 | -3.978583 | -10.543299 | |
Bibb County | 50.0 | 3.0 | 6.0 | 1.0 | 7.0 | 22915.0 | 22919.0 | 22861.0 | 22733.0 | 22642.0 | ... | -5.527043 | -5.068871 | -6.201001 | -0.177537 | 0.177258 | -5.088389 | -4.363636 | -5.403729 | 0.754533 | 1.107861 | |
Blount County | 50.0 | 3.0 | 6.0 | 1.0 | 9.0 | 57322.0 | 57322.0 | 57373.0 | 57711.0 | 57776.0 | ... | 1.807375 | -1.177622 | -1.748766 | -2.062535 | -1.369970 | 1.859511 | -0.848580 | -1.402476 | -1.577232 | -0.884411 | |
Bullock County | 50.0 | 3.0 | 6.0 | 1.0 | 11.0 | 10914.0 | 10915.0 | 10887.0 | 10629.0 | 10606.0 | ... | -30.953709 | -5.180127 | -1.130263 | 14.354290 | -16.167247 | -29.001673 | -2.825524 | 1.507017 | 17.243790 | -13.193961 | |
Butler County | 50.0 | 3.0 | 6.0 | 1.0 | 13.0 | 20947.0 | 20946.0 | 20944.0 | 20673.0 | 20408.0 | ... | -14.032727 | -11.684234 | -5.655413 | 1.085428 | -6.529805 | -13.936612 | -11.586865 | -5.557058 | 1.184103 | -6.430868 | |
Calhoun County | 50.0 | 3.0 | 6.0 | 1.0 | 15.0 | 118572.0 | 118586.0 | 118437.0 | 117768.0 | 117286.0 | ... | -6.155670 | -4.611706 | -5.524649 | -4.463211 | -3.376322 | -5.791579 | -4.092677 | -5.062836 | -3.912834 | -2.806406 | |
Chambers County | 50.0 | 3.0 | 6.0 | 1.0 | 17.0 | 34215.0 | 34170.0 | 34098.0 | 33993.0 | 34075.0 | ... | -2.731639 | 3.849092 | 2.872721 | -2.287222 | 1.349468 | -1.821092 | 4.701181 | 3.781439 | -1.290228 | 2.346901 | |
Cherokee County | 50.0 | 3.0 | 6.0 | 1.0 | 19.0 | 25989.0 | 25986.0 | 25976.0 | 26080.0 | 26023.0 | ... | 6.339327 | 1.113180 | 5.488706 | -0.076806 | -3.239866 | 6.416167 | 1.420264 | 5.757384 | 0.230419 | -2.931307 | |
Chilton County | 50.0 | 3.0 | 6.0 | 1.0 | 21.0 | 43643.0 | 43631.0 | 43665.0 | 43739.0 | 43697.0 | ... | -1.372935 | -2.653369 | 0.480044 | 0.456017 | -2.253483 | -0.823761 | -2.447504 | 0.868651 | 0.957636 | -1.752709 | |
Choctaw County | 50.0 | 3.0 | 6.0 | 1.0 | 23.0 | 13859.0 | 13858.0 | 13841.0 | 13593.0 | 13543.0 | ... | -15.455274 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | -15.528177 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | |
Clarke County | 50.0 | 3.0 | 6.0 | 1.0 | 25.0 | 25833.0 | 25840.0 | 25767.0 | 25570.0 | 25144.0 | ... | -6.194363 | -17.667705 | -0.318345 | -8.686428 | -5.613667 | -6.077488 | -17.509958 | -0.159172 | -8.486280 | -5.411736 | |
Clay County | 50.0 | 3.0 | 6.0 | 1.0 | 27.0 | 13932.0 | 13932.0 | 13880.0 | 13670.0 | 13456.0 | ... | -10.744102 | -13.345130 | 4.902871 | 5.702648 | 3.912450 | -10.816697 | -13.345130 | 4.977157 | 5.776708 | 3.986270 | |
Cleburne County | 50.0 | 3.0 | 6.0 | 1.0 | 29.0 | 14972.0 | 14972.0 | 14973.0 | 14971.0 | 14921.0 | ... | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | |
Coffee County | 50.0 | 3.0 | 6.0 | 1.0 | 31.0 | 49948.0 | 49948.0 | 50177.0 | 50448.0 | 51173.0 | ... | 0.377640 | 7.675579 | -13.146535 | -3.602859 | 2.214774 | 2.166460 | 11.513368 | -10.438741 | -0.767822 | 5.350738 | |
Colbert County | 50.0 | 3.0 | 6.0 | 1.0 | 33.0 | 54428.0 | 54428.0 | 54514.0 | 54443.0 | 54472.0 | ... | -0.073423 | 1.065051 | 1.762390 | 1.835688 | -0.110260 | 0.513964 | 1.469035 | 2.276420 | 2.533249 | 0.588052 | |
Conecuh County | 50.0 | 3.0 | 6.0 | 1.0 | 35.0 | 13228.0 | 13228.0 | 13208.0 | 13121.0 | 12996.0 | ... | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | |
Coosa County | 50.0 | 3.0 | 6.0 | 1.0 | 37.0 | 11539.0 | 11758.0 | 11758.0 | 11348.0 | 11195.0 | ... | -33.930581 | -10.291443 | -4.313831 | -22.958017 | -5.387581 | -34.017138 | -10.380162 | -4.403703 | -23.049483 | -5.387581 | |
Covington County | 50.0 | 3.0 | 6.0 | 1.0 | 39.0 | 37765.0 | 37765.0 | 37796.0 | 38060.0 | 37818.0 | ... | 6.696899 | -4.612668 | 0.740271 | 3.697932 | -0.316945 | 6.881460 | -4.559952 | 0.793147 | 3.750759 | -0.264121 | |
Crenshaw County | 50.0 | 3.0 | 6.0 | 1.0 | 41.0 | 13906.0 | 13906.0 | 13853.0 | 13896.0 | 13951.0 | ... | 1.729792 | 3.950156 | -1.864936 | 3.084648 | 3.439504 | 2.666763 | 5.099293 | -0.502098 | 4.734577 | 5.087600 | |
Cullman County | 50.0 | 3.0 | 6.0 | 1.0 | 43.0 | 80406.0 | 80410.0 | 80473.0 | 80469.0 | 80374.0 | ... | -1.404233 | -1.019628 | 4.071247 | 5.087142 | 7.915406 | -1.031427 | -0.634159 | 4.542916 | 5.593387 | 8.417777 | |
Dale County | 50.0 | 3.0 | 6.0 | 1.0 | 45.0 | 50251.0 | 50251.0 | 50358.0 | 50109.0 | 50324.0 | ... | -10.749798 | -5.277150 | -15.236079 | -11.979785 | -5.107706 | -9.575283 | -0.776637 | -12.640155 | -9.503292 | -1.998668 | |
Dallas County | 50.0 | 3.0 | 6.0 | 1.0 | 47.0 | 43820.0 | 43820.0 | 43803.0 | 43178.0 | 42777.0 | ... | -15.635599 | -11.308243 | -16.745678 | -9.344789 | -14.687232 | -15.727573 | -11.378047 | -16.792849 | -9.368689 | -14.711389 | |
DeKalb County | 50.0 | 3.0 | 6.0 | 1.0 | 49.0 | 71109.0 | 71115.0 | 71142.0 | 71387.0 | 70942.0 | ... | 0.294677 | -9.302391 | -1.748807 | 0.267830 | 0.028141 | 1.375159 | -8.656001 | -1.029539 | 1.198187 | 0.956790 | |
Elmore County | 50.0 | 3.0 | 6.0 | 1.0 | 51.0 | 79303.0 | 79296.0 | 79465.0 | 80012.0 | 80432.0 | ... | 3.235576 | 0.822717 | 1.760531 | -1.507057 | 2.067820 | 3.674511 | 1.558176 | 2.306047 | -0.951175 | 2.757093 | |
Escambia County | 50.0 | 3.0 | 6.0 | 1.0 | 53.0 | 38319.0 | 38319.0 | 38309.0 | 38213.0 | 38034.0 | ... | -3.449988 | -3.855889 | -4.822706 | -1.189831 | 1.190902 | -3.397716 | -3.803428 | -4.769999 | -1.136950 | 1.243830 | |
Etowah County | 50.0 | 3.0 | 6.0 | 1.0 | 55.0 | 104430.0 | 104427.0 | 104442.0 | 104236.0 | 104235.0 | ... | -1.015919 | 2.062637 | -1.931884 | -1.726932 | -2.082234 | -0.632554 | 2.446383 | -1.518596 | -1.234901 | -1.588308 | |
Fayette County | 50.0 | 3.0 | 6.0 | 1.0 | 57.0 | 17241.0 | 17241.0 | 17231.0 | 17062.0 | 16960.0 | ... | -5.015601 | -0.646640 | -3.725937 | 0.296745 | -2.797536 | -5.132243 | -0.705426 | -3.785079 | 0.237396 | -2.857058 | |
Franklin County | 50.0 | 3.0 | 6.0 | 1.0 | 59.0 | 31704.0 | 31709.0 | 31734.0 | 31729.0 | 31648.0 | ... | -1.638750 | -5.459394 | -8.043702 | -1.267849 | -2.401719 | 0.063029 | -3.471291 | -5.700261 | 1.553115 | 0.442422 | |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Wisconsin | Washburn County | 50.0 | 2.0 | 3.0 | 55.0 | 129.0 | 15911.0 | 15911.0 | 15930.0 | 15784.0 | 15831.0 | ... | -6.873936 | 7.338289 | -6.732724 | 3.510452 | -5.123279 | -6.747809 | 7.464811 | -6.605691 | 3.638104 | -4.995197 |
Washington County | 50.0 | 2.0 | 3.0 | 55.0 | 131.0 | 131887.0 | 131885.0 | 131967.0 | 132225.0 | 132649.0 | ... | -0.794876 | 0.785279 | -2.215465 | 1.601149 | -0.434498 | -0.431504 | 1.162817 | -1.763330 | 2.104796 | 0.059931 | |
Waukesha County | 50.0 | 2.0 | 3.0 | 55.0 | 133.0 | 389891.0 | 389938.0 | 390076.0 | 390808.0 | 392710.0 | ... | -0.765799 | 2.128860 | 0.038132 | 0.760109 | -0.719858 | 0.102448 | 3.180527 | 1.189727 | 2.077633 | 0.593567 | |
Waupaca County | 50.0 | 2.0 | 3.0 | 55.0 | 135.0 | 52410.0 | 52410.0 | 52422.0 | 52342.0 | 52035.0 | ... | 3.111756 | -2.241873 | 6.292687 | -0.441031 | -0.480617 | 3.359933 | -2.011937 | 6.561277 | -0.134227 | -0.173022 | |
Waushara County | 50.0 | 2.0 | 3.0 | 55.0 | 137.0 | 24496.0 | 24496.0 | 24506.0 | 24581.0 | 24484.0 | ... | 4.930022 | -2.404973 | -4.097017 | -4.906711 | -4.397793 | 5.174486 | -2.160399 | -3.810226 | -4.535615 | -4.024395 | |
Winnebago County | 50.0 | 2.0 | 3.0 | 55.0 | 139.0 | 166994.0 | 166994.0 | 167059.0 | 167630.0 | 168717.0 | ... | 0.316712 | 2.889873 | 0.833819 | -2.406192 | -4.557985 | 0.842573 | 3.502335 | 1.531624 | -1.545153 | -3.685304 | |
Wood County | 50.0 | 2.0 | 3.0 | 55.0 | 141.0 | 74749.0 | 74749.0 | 74807.0 | 74647.0 | 74384.0 | ... | -4.081523 | -5.019090 | -6.901200 | -5.596471 | -3.958322 | -3.733590 | -4.562809 | -6.442917 | -5.040889 | -3.414223 | |
Wyoming | Albany County | 50.0 | 4.0 | 8.0 | 56.0 | 1.0 | 36299.0 | 36299.0 | 36428.0 | 36908.0 | 37396.0 | ... | 3.708956 | 2.637812 | -3.544634 | -3.334877 | -9.911169 | 6.736119 | 6.433032 | 0.719587 | 1.429233 | -5.166460 |
Big Horn County | 50.0 | 4.0 | 8.0 | 56.0 | 3.0 | 11668.0 | 11668.0 | 11672.0 | 11745.0 | 11785.0 | ... | 4.868258 | 2.804930 | 16.815908 | -8.026420 | 5.095861 | 4.868258 | 3.144921 | 17.236306 | -7.608378 | 5.513554 | |
Campbell County | 50.0 | 4.0 | 8.0 | 56.0 | 5.0 | 46133.0 | 46133.0 | 46244.0 | 46600.0 | 47881.0 | ... | -2.843479 | 15.601020 | -5.895711 | -8.550911 | 10.916963 | -2.649606 | 15.558684 | -5.916543 | -8.509402 | 10.978525 | |
Carbon County | 50.0 | 4.0 | 8.0 | 56.0 | 7.0 | 15885.0 | 15885.0 | 15837.0 | 15817.0 | 15678.0 | ... | -7.581980 | -13.081441 | 3.178134 | -2.970641 | -23.300971 | -7.392431 | -12.636926 | 3.623073 | -2.338590 | -22.600668 | |
Converse County | 50.0 | 4.0 | 8.0 | 56.0 | 9.0 | 13833.0 | 13833.0 | 13826.0 | 13728.0 | 14025.0 | ... | -12.847499 | 15.493820 | 19.035533 | -20.550587 | -0.070403 | -12.774915 | 16.502720 | 20.093063 | -19.358233 | 1.126443 | |
Crook County | 50.0 | 4.0 | 8.0 | 56.0 | 11.0 | 7083.0 | 7083.0 | 7114.0 | 7129.0 | 7148.0 | ... | -1.544618 | -4.202564 | 1.397819 | 6.378258 | 18.629317 | -0.982939 | -3.642222 | 2.096729 | 7.071547 | 19.309219 | |
Fremont County | 50.0 | 4.0 | 8.0 | 56.0 | 13.0 | 40123.0 | 40123.0 | 40222.0 | 40591.0 | 41129.0 | ... | 2.747083 | 7.782673 | -4.990688 | -12.331633 | -13.673610 | 3.093562 | 8.027411 | -4.747240 | -12.013555 | -13.352750 | |
Goshen County | 50.0 | 4.0 | 8.0 | 56.0 | 15.0 | 13249.0 | 13247.0 | 13408.0 | 13597.0 | 13666.0 | ... | 14.293649 | 3.961413 | -8.079028 | -7.017803 | -11.899450 | 14.886132 | 4.841727 | -6.903896 | -5.761986 | -10.635133 | |
Hot Springs County | 50.0 | 4.0 | 8.0 | 56.0 | 17.0 | 4812.0 | 4812.0 | 4813.0 | 4818.0 | 4846.0 | ... | 3.322604 | 6.208609 | 3.095336 | -6.017222 | -5.454164 | 5.191569 | 6.001656 | 2.888981 | -6.224712 | -5.663940 | |
Johnson County | 50.0 | 4.0 | 8.0 | 56.0 | 19.0 | 8569.0 | 8569.0 | 8581.0 | 8636.0 | 8610.0 | ... | 4.995063 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | 5.227392 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | |
Laramie County | 50.0 | 4.0 | 8.0 | 56.0 | 21.0 | 91738.0 | 91881.0 | 92271.0 | 92663.0 | 94894.0 | ... | -1.200428 | 15.547274 | 4.787847 | -1.226133 | 0.278940 | -0.973320 | 17.914554 | 6.003143 | -0.207819 | 1.673640 | |
Lincoln County | 50.0 | 4.0 | 8.0 | 56.0 | 23.0 | 18106.0 | 18106.0 | 18091.0 | 18022.0 | 17943.0 | ... | -9.802564 | -11.566801 | 13.564556 | 6.125989 | 1.555544 | -9.691801 | -11.566801 | 13.619696 | 6.234414 | 1.662823 | |
Natrona County | 50.0 | 4.0 | 8.0 | 56.0 | 25.0 | 75450.0 | 75450.0 | 75472.0 | 76420.0 | 78699.0 | ... | 7.189319 | 23.066162 | 24.322042 | -0.958472 | -0.061057 | 7.689674 | 23.749508 | 25.085233 | -0.110593 | 0.793743 | |
Niobrara County | 50.0 | 4.0 | 8.0 | 56.0 | 27.0 | 2484.0 | 2484.0 | 2492.0 | 2485.0 | 2475.0 | ... | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | |
Park County | 50.0 | 4.0 | 8.0 | 56.0 | 29.0 | 28205.0 | 28205.0 | 28259.0 | 28473.0 | 28863.0 | ... | 4.582951 | 8.057765 | 7.641997 | -9.252437 | -2.878980 | 6.486639 | 11.127389 | 10.877797 | -5.585731 | 0.856839 | |
Platte County | 50.0 | 4.0 | 8.0 | 56.0 | 31.0 | 8667.0 | 8667.0 | 8678.0 | 8701.0 | 8732.0 | ... | 4.373094 | 5.392073 | 2.634593 | 6.055759 | 4.662270 | 4.373094 | 4.933173 | 2.176403 | 5.598720 | 4.207414 | |
Sheridan County | 50.0 | 4.0 | 8.0 | 56.0 | 33.0 | 29116.0 | 29116.0 | 29146.0 | 29275.0 | 29594.0 | ... | 0.958559 | 8.425487 | 4.546373 | 3.678069 | -3.298406 | 2.122524 | 9.342778 | 5.523001 | 4.781489 | -2.198937 | |
Sublette County | 50.0 | 4.0 | 8.0 | 56.0 | 35.0 | 10247.0 | 10247.0 | 10244.0 | 10142.0 | 10418.0 | ... | -23.741784 | 15.272374 | -40.870074 | -16.596273 | -22.870900 | -21.092907 | 16.828794 | -39.211861 | -14.409938 | -20.664059 | |
Sweetwater County | 50.0 | 4.0 | 8.0 | 56.0 | 37.0 | 43806.0 | 43806.0 | 43593.0 | 44041.0 | 45104.0 | ... | 1.072643 | 16.243199 | -5.339774 | -14.252889 | -14.248864 | 1.255221 | 16.243199 | -5.295460 | -14.075283 | -14.070195 | |
Teton County | 50.0 | 4.0 | 8.0 | 56.0 | 39.0 | 21294.0 | 21294.0 | 21297.0 | 21482.0 | 21697.0 | ... | -1.589565 | 0.972695 | 19.525929 | 14.143021 | -0.564849 | 0.654527 | 2.408578 | 21.160658 | 16.308671 | 1.520747 | |
Uinta County | 50.0 | 4.0 | 8.0 | 56.0 | 41.0 | 21118.0 | 21118.0 | 21102.0 | 20912.0 | 20989.0 | ... | -17.755986 | -4.916350 | -6.902954 | -14.215862 | -12.127022 | -18.136812 | -5.536861 | -7.521840 | -14.740608 | -12.606351 | |
Washakie County | 50.0 | 4.0 | 8.0 | 56.0 | 43.0 | 8533.0 | 8533.0 | 8545.0 | 8469.0 | 8443.0 | ... | -11.637475 | -0.827815 | -2.013502 | -17.781491 | 1.682288 | -11.990126 | -1.182592 | -2.250385 | -18.020168 | 1.441961 | |
Weston County | 50.0 | 4.0 | 8.0 | 56.0 | 45.0 | 7208.0 | 7208.0 | 7181.0 | 7114.0 | 7065.0 | ... | -11.752361 | -8.040059 | 12.372583 | 1.533635 | 6.935294 | -12.032179 | -8.040059 | 12.372583 | 1.533635 | 6.935294 |
3142 rows × 98 columns
df = df[df['SUMLEV']==50]
df.set_index(['STNAME','CTYNAME'], inplace=True)
df.rename(columns={'ESTIMATESBASE2010': 'Estimates Base 2010'})
SUMLEV | REGION | DIVISION | STATE | COUNTY | CENSUS2010POP | Estimates Base 2010 | POPESTIMATE2010 | POPESTIMATE2011 | POPESTIMATE2012 | ... | RDOMESTICMIG2011 | RDOMESTICMIG2012 | RDOMESTICMIG2013 | RDOMESTICMIG2014 | RDOMESTICMIG2015 | RNETMIG2011 | RNETMIG2012 | RNETMIG2013 | RNETMIG2014 | RNETMIG2015 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STNAME | CTYNAME | |||||||||||||||||||||
Alabama | Autauga County | 50 | 3 | 6 | 1 | 1 | 54571 | 54571 | 54660 | 55253 | 55175 | ... | 7.242091 | -2.915927 | -3.012349 | 2.265971 | -2.530799 | 7.606016 | -2.626146 | -2.722002 | 2.592270 | -2.187333 |
Baldwin County | 50 | 3 | 6 | 1 | 3 | 182265 | 182265 | 183193 | 186659 | 190396 | ... | 14.832960 | 17.647293 | 21.845705 | 19.243287 | 17.197872 | 15.844176 | 18.559627 | 22.727626 | 20.317142 | 18.293499 | |
Barbour County | 50 | 3 | 6 | 1 | 5 | 27457 | 27457 | 27341 | 27226 | 27159 | ... | -4.728132 | -2.500690 | -7.056824 | -3.904217 | -10.543299 | -4.874741 | -2.758113 | -7.167664 | -3.978583 | -10.543299 | |
Bibb County | 50 | 3 | 6 | 1 | 7 | 22915 | 22919 | 22861 | 22733 | 22642 | ... | -5.527043 | -5.068871 | -6.201001 | -0.177537 | 0.177258 | -5.088389 | -4.363636 | -5.403729 | 0.754533 | 1.107861 | |
Blount County | 50 | 3 | 6 | 1 | 9 | 57322 | 57322 | 57373 | 57711 | 57776 | ... | 1.807375 | -1.177622 | -1.748766 | -2.062535 | -1.369970 | 1.859511 | -0.848580 | -1.402476 | -1.577232 | -0.884411 | |
Bullock County | 50 | 3 | 6 | 1 | 11 | 10914 | 10915 | 10887 | 10629 | 10606 | ... | -30.953709 | -5.180127 | -1.130263 | 14.354290 | -16.167247 | -29.001673 | -2.825524 | 1.507017 | 17.243790 | -13.193961 | |
Butler County | 50 | 3 | 6 | 1 | 13 | 20947 | 20946 | 20944 | 20673 | 20408 | ... | -14.032727 | -11.684234 | -5.655413 | 1.085428 | -6.529805 | -13.936612 | -11.586865 | -5.557058 | 1.184103 | -6.430868 | |
Calhoun County | 50 | 3 | 6 | 1 | 15 | 118572 | 118586 | 118437 | 117768 | 117286 | ... | -6.155670 | -4.611706 | -5.524649 | -4.463211 | -3.376322 | -5.791579 | -4.092677 | -5.062836 | -3.912834 | -2.806406 | |
Chambers County | 50 | 3 | 6 | 1 | 17 | 34215 | 34170 | 34098 | 33993 | 34075 | ... | -2.731639 | 3.849092 | 2.872721 | -2.287222 | 1.349468 | -1.821092 | 4.701181 | 3.781439 | -1.290228 | 2.346901 | |
Cherokee County | 50 | 3 | 6 | 1 | 19 | 25989 | 25986 | 25976 | 26080 | 26023 | ... | 6.339327 | 1.113180 | 5.488706 | -0.076806 | -3.239866 | 6.416167 | 1.420264 | 5.757384 | 0.230419 | -2.931307 | |
Chilton County | 50 | 3 | 6 | 1 | 21 | 43643 | 43631 | 43665 | 43739 | 43697 | ... | -1.372935 | -2.653369 | 0.480044 | 0.456017 | -2.253483 | -0.823761 | -2.447504 | 0.868651 | 0.957636 | -1.752709 | |
Choctaw County | 50 | 3 | 6 | 1 | 23 | 13859 | 13858 | 13841 | 13593 | 13543 | ... | -15.455274 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | -15.528177 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | |
Clarke County | 50 | 3 | 6 | 1 | 25 | 25833 | 25840 | 25767 | 25570 | 25144 | ... | -6.194363 | -17.667705 | -0.318345 | -8.686428 | -5.613667 | -6.077488 | -17.509958 | -0.159172 | -8.486280 | -5.411736 | |
Clay County | 50 | 3 | 6 | 1 | 27 | 13932 | 13932 | 13880 | 13670 | 13456 | ... | -10.744102 | -13.345130 | 4.902871 | 5.702648 | 3.912450 | -10.816697 | -13.345130 | 4.977157 | 5.776708 | 3.986270 | |
Cleburne County | 50 | 3 | 6 | 1 | 29 | 14972 | 14972 | 14973 | 14971 | 14921 | ... | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | |
Coffee County | 50 | 3 | 6 | 1 | 31 | 49948 | 49948 | 50177 | 50448 | 51173 | ... | 0.377640 | 7.675579 | -13.146535 | -3.602859 | 2.214774 | 2.166460 | 11.513368 | -10.438741 | -0.767822 | 5.350738 | |
Colbert County | 50 | 3 | 6 | 1 | 33 | 54428 | 54428 | 54514 | 54443 | 54472 | ... | -0.073423 | 1.065051 | 1.762390 | 1.835688 | -0.110260 | 0.513964 | 1.469035 | 2.276420 | 2.533249 | 0.588052 | |
Conecuh County | 50 | 3 | 6 | 1 | 35 | 13228 | 13228 | 13208 | 13121 | 12996 | ... | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | |
Coosa County | 50 | 3 | 6 | 1 | 37 | 11539 | 11758 | 11758 | 11348 | 11195 | ... | -33.930581 | -10.291443 | -4.313831 | -22.958017 | -5.387581 | -34.017138 | -10.380162 | -4.403703 | -23.049483 | -5.387581 | |
Covington County | 50 | 3 | 6 | 1 | 39 | 37765 | 37765 | 37796 | 38060 | 37818 | ... | 6.696899 | -4.612668 | 0.740271 | 3.697932 | -0.316945 | 6.881460 | -4.559952 | 0.793147 | 3.750759 | -0.264121 | |
Crenshaw County | 50 | 3 | 6 | 1 | 41 | 13906 | 13906 | 13853 | 13896 | 13951 | ... | 1.729792 | 3.950156 | -1.864936 | 3.084648 | 3.439504 | 2.666763 | 5.099293 | -0.502098 | 4.734577 | 5.087600 | |
Cullman County | 50 | 3 | 6 | 1 | 43 | 80406 | 80410 | 80473 | 80469 | 80374 | ... | -1.404233 | -1.019628 | 4.071247 | 5.087142 | 7.915406 | -1.031427 | -0.634159 | 4.542916 | 5.593387 | 8.417777 | |
Dale County | 50 | 3 | 6 | 1 | 45 | 50251 | 50251 | 50358 | 50109 | 50324 | ... | -10.749798 | -5.277150 | -15.236079 | -11.979785 | -5.107706 | -9.575283 | -0.776637 | -12.640155 | -9.503292 | -1.998668 | |
Dallas County | 50 | 3 | 6 | 1 | 47 | 43820 | 43820 | 43803 | 43178 | 42777 | ... | -15.635599 | -11.308243 | -16.745678 | -9.344789 | -14.687232 | -15.727573 | -11.378047 | -16.792849 | -9.368689 | -14.711389 | |
DeKalb County | 50 | 3 | 6 | 1 | 49 | 71109 | 71115 | 71142 | 71387 | 70942 | ... | 0.294677 | -9.302391 | -1.748807 | 0.267830 | 0.028141 | 1.375159 | -8.656001 | -1.029539 | 1.198187 | 0.956790 | |
Elmore County | 50 | 3 | 6 | 1 | 51 | 79303 | 79296 | 79465 | 80012 | 80432 | ... | 3.235576 | 0.822717 | 1.760531 | -1.507057 | 2.067820 | 3.674511 | 1.558176 | 2.306047 | -0.951175 | 2.757093 | |
Escambia County | 50 | 3 | 6 | 1 | 53 | 38319 | 38319 | 38309 | 38213 | 38034 | ... | -3.449988 | -3.855889 | -4.822706 | -1.189831 | 1.190902 | -3.397716 | -3.803428 | -4.769999 | -1.136950 | 1.243830 | |
Etowah County | 50 | 3 | 6 | 1 | 55 | 104430 | 104427 | 104442 | 104236 | 104235 | ... | -1.015919 | 2.062637 | -1.931884 | -1.726932 | -2.082234 | -0.632554 | 2.446383 | -1.518596 | -1.234901 | -1.588308 | |
Fayette County | 50 | 3 | 6 | 1 | 57 | 17241 | 17241 | 17231 | 17062 | 16960 | ... | -5.015601 | -0.646640 | -3.725937 | 0.296745 | -2.797536 | -5.132243 | -0.705426 | -3.785079 | 0.237396 | -2.857058 | |
Franklin County | 50 | 3 | 6 | 1 | 59 | 31704 | 31709 | 31734 | 31729 | 31648 | ... | -1.638750 | -5.459394 | -8.043702 | -1.267849 | -2.401719 | 0.063029 | -3.471291 | -5.700261 | 1.553115 | 0.442422 | |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Wisconsin | Washburn County | 50 | 2 | 3 | 55 | 129 | 15911 | 15911 | 15930 | 15784 | 15831 | ... | -6.873936 | 7.338289 | -6.732724 | 3.510452 | -5.123279 | -6.747809 | 7.464811 | -6.605691 | 3.638104 | -4.995197 |
Washington County | 50 | 2 | 3 | 55 | 131 | 131887 | 131885 | 131967 | 132225 | 132649 | ... | -0.794876 | 0.785279 | -2.215465 | 1.601149 | -0.434498 | -0.431504 | 1.162817 | -1.763330 | 2.104796 | 0.059931 | |
Waukesha County | 50 | 2 | 3 | 55 | 133 | 389891 | 389938 | 390076 | 390808 | 392710 | ... | -0.765799 | 2.128860 | 0.038132 | 0.760109 | -0.719858 | 0.102448 | 3.180527 | 1.189727 | 2.077633 | 0.593567 | |
Waupaca County | 50 | 2 | 3 | 55 | 135 | 52410 | 52410 | 52422 | 52342 | 52035 | ... | 3.111756 | -2.241873 | 6.292687 | -0.441031 | -0.480617 | 3.359933 | -2.011937 | 6.561277 | -0.134227 | -0.173022 | |
Waushara County | 50 | 2 | 3 | 55 | 137 | 24496 | 24496 | 24506 | 24581 | 24484 | ... | 4.930022 | -2.404973 | -4.097017 | -4.906711 | -4.397793 | 5.174486 | -2.160399 | -3.810226 | -4.535615 | -4.024395 | |
Winnebago County | 50 | 2 | 3 | 55 | 139 | 166994 | 166994 | 167059 | 167630 | 168717 | ... | 0.316712 | 2.889873 | 0.833819 | -2.406192 | -4.557985 | 0.842573 | 3.502335 | 1.531624 | -1.545153 | -3.685304 | |
Wood County | 50 | 2 | 3 | 55 | 141 | 74749 | 74749 | 74807 | 74647 | 74384 | ... | -4.081523 | -5.019090 | -6.901200 | -5.596471 | -3.958322 | -3.733590 | -4.562809 | -6.442917 | -5.040889 | -3.414223 | |
Wyoming | Albany County | 50 | 4 | 8 | 56 | 1 | 36299 | 36299 | 36428 | 36908 | 37396 | ... | 3.708956 | 2.637812 | -3.544634 | -3.334877 | -9.911169 | 6.736119 | 6.433032 | 0.719587 | 1.429233 | -5.166460 |
Big Horn County | 50 | 4 | 8 | 56 | 3 | 11668 | 11668 | 11672 | 11745 | 11785 | ... | 4.868258 | 2.804930 | 16.815908 | -8.026420 | 5.095861 | 4.868258 | 3.144921 | 17.236306 | -7.608378 | 5.513554 | |
Campbell County | 50 | 4 | 8 | 56 | 5 | 46133 | 46133 | 46244 | 46600 | 47881 | ... | -2.843479 | 15.601020 | -5.895711 | -8.550911 | 10.916963 | -2.649606 | 15.558684 | -5.916543 | -8.509402 | 10.978525 | |
Carbon County | 50 | 4 | 8 | 56 | 7 | 15885 | 15885 | 15837 | 15817 | 15678 | ... | -7.581980 | -13.081441 | 3.178134 | -2.970641 | -23.300971 | -7.392431 | -12.636926 | 3.623073 | -2.338590 | -22.600668 | |
Converse County | 50 | 4 | 8 | 56 | 9 | 13833 | 13833 | 13826 | 13728 | 14025 | ... | -12.847499 | 15.493820 | 19.035533 | -20.550587 | -0.070403 | -12.774915 | 16.502720 | 20.093063 | -19.358233 | 1.126443 | |
Crook County | 50 | 4 | 8 | 56 | 11 | 7083 | 7083 | 7114 | 7129 | 7148 | ... | -1.544618 | -4.202564 | 1.397819 | 6.378258 | 18.629317 | -0.982939 | -3.642222 | 2.096729 | 7.071547 | 19.309219 | |
Fremont County | 50 | 4 | 8 | 56 | 13 | 40123 | 40123 | 40222 | 40591 | 41129 | ... | 2.747083 | 7.782673 | -4.990688 | -12.331633 | -13.673610 | 3.093562 | 8.027411 | -4.747240 | -12.013555 | -13.352750 | |
Goshen County | 50 | 4 | 8 | 56 | 15 | 13249 | 13247 | 13408 | 13597 | 13666 | ... | 14.293649 | 3.961413 | -8.079028 | -7.017803 | -11.899450 | 14.886132 | 4.841727 | -6.903896 | -5.761986 | -10.635133 | |
Hot Springs County | 50 | 4 | 8 | 56 | 17 | 4812 | 4812 | 4813 | 4818 | 4846 | ... | 3.322604 | 6.208609 | 3.095336 | -6.017222 | -5.454164 | 5.191569 | 6.001656 | 2.888981 | -6.224712 | -5.663940 | |
Johnson County | 50 | 4 | 8 | 56 | 19 | 8569 | 8569 | 8581 | 8636 | 8610 | ... | 4.995063 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | 5.227392 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | |
Laramie County | 50 | 4 | 8 | 56 | 21 | 91738 | 91881 | 92271 | 92663 | 94894 | ... | -1.200428 | 15.547274 | 4.787847 | -1.226133 | 0.278940 | -0.973320 | 17.914554 | 6.003143 | -0.207819 | 1.673640 | |
Lincoln County | 50 | 4 | 8 | 56 | 23 | 18106 | 18106 | 18091 | 18022 | 17943 | ... | -9.802564 | -11.566801 | 13.564556 | 6.125989 | 1.555544 | -9.691801 | -11.566801 | 13.619696 | 6.234414 | 1.662823 | |
Natrona County | 50 | 4 | 8 | 56 | 25 | 75450 | 75450 | 75472 | 76420 | 78699 | ... | 7.189319 | 23.066162 | 24.322042 | -0.958472 | -0.061057 | 7.689674 | 23.749508 | 25.085233 | -0.110593 | 0.793743 | |
Niobrara County | 50 | 4 | 8 | 56 | 27 | 2484 | 2484 | 2492 | 2485 | 2475 | ... | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | |
Park County | 50 | 4 | 8 | 56 | 29 | 28205 | 28205 | 28259 | 28473 | 28863 | ... | 4.582951 | 8.057765 | 7.641997 | -9.252437 | -2.878980 | 6.486639 | 11.127389 | 10.877797 | -5.585731 | 0.856839 | |
Platte County | 50 | 4 | 8 | 56 | 31 | 8667 | 8667 | 8678 | 8701 | 8732 | ... | 4.373094 | 5.392073 | 2.634593 | 6.055759 | 4.662270 | 4.373094 | 4.933173 | 2.176403 | 5.598720 | 4.207414 | |
Sheridan County | 50 | 4 | 8 | 56 | 33 | 29116 | 29116 | 29146 | 29275 | 29594 | ... | 0.958559 | 8.425487 | 4.546373 | 3.678069 | -3.298406 | 2.122524 | 9.342778 | 5.523001 | 4.781489 | -2.198937 | |
Sublette County | 50 | 4 | 8 | 56 | 35 | 10247 | 10247 | 10244 | 10142 | 10418 | ... | -23.741784 | 15.272374 | -40.870074 | -16.596273 | -22.870900 | -21.092907 | 16.828794 | -39.211861 | -14.409938 | -20.664059 | |
Sweetwater County | 50 | 4 | 8 | 56 | 37 | 43806 | 43806 | 43593 | 44041 | 45104 | ... | 1.072643 | 16.243199 | -5.339774 | -14.252889 | -14.248864 | 1.255221 | 16.243199 | -5.295460 | -14.075283 | -14.070195 | |
Teton County | 50 | 4 | 8 | 56 | 39 | 21294 | 21294 | 21297 | 21482 | 21697 | ... | -1.589565 | 0.972695 | 19.525929 | 14.143021 | -0.564849 | 0.654527 | 2.408578 | 21.160658 | 16.308671 | 1.520747 | |
Uinta County | 50 | 4 | 8 | 56 | 41 | 21118 | 21118 | 21102 | 20912 | 20989 | ... | -17.755986 | -4.916350 | -6.902954 | -14.215862 | -12.127022 | -18.136812 | -5.536861 | -7.521840 | -14.740608 | -12.606351 | |
Washakie County | 50 | 4 | 8 | 56 | 43 | 8533 | 8533 | 8545 | 8469 | 8443 | ... | -11.637475 | -0.827815 | -2.013502 | -17.781491 | 1.682288 | -11.990126 | -1.182592 | -2.250385 | -18.020168 | 1.441961 | |
Weston County | 50 | 4 | 8 | 56 | 45 | 7208 | 7208 | 7181 | 7114 | 7065 | ... | -11.752361 | -8.040059 | 12.372583 | 1.533635 | 6.935294 | -12.032179 | -8.040059 | 12.372583 | 1.533635 | 6.935294 |
3142 rows × 98 columns
import numpy as np
def min_max(row):
data = row[['POPESTIMATE2010',
'POPESTIMATE2011',
'POPESTIMATE2012',
'POPESTIMATE2013',
'POPESTIMATE2014',
'POPESTIMATE2015']]
return pd.Series({'min': np.min(data), 'max': np.max(data)})
df.apply(min_max, axis=1)
max | min | ||
---|---|---|---|
STNAME | CTYNAME | ||
Alabama | Autauga County | 55347.0 | 54660.0 |
Baldwin County | 203709.0 | 183193.0 | |
Barbour County | 27341.0 | 26489.0 | |
Bibb County | 22861.0 | 22512.0 | |
Blount County | 57776.0 | 57373.0 | |
Bullock County | 10887.0 | 10606.0 | |
Butler County | 20944.0 | 20154.0 | |
Calhoun County | 118437.0 | 115620.0 | |
Chambers County | 34153.0 | 33993.0 | |
Cherokee County | 26084.0 | 25859.0 | |
Chilton County | 43943.0 | 43665.0 | |
Choctaw County | 13841.0 | 13170.0 | |
Clarke County | 25767.0 | 24675.0 | |
Clay County | 13880.0 | 13456.0 | |
Cleburne County | 15072.0 | 14921.0 | |
Coffee County | 51211.0 | 50177.0 | |
Colbert County | 54514.0 | 54354.0 | |
Conecuh County | 13208.0 | 12662.0 | |
Coosa County | 11758.0 | 10724.0 | |
Covington County | 38060.0 | 37796.0 | |
Crenshaw County | 13963.0 | 13853.0 | |
Cullman County | 82005.0 | 80374.0 | |
Dale County | 50358.0 | 49501.0 | |
Dallas County | 43803.0 | 41131.0 | |
DeKalb County | 71387.0 | 70869.0 | |
Elmore County | 81468.0 | 79465.0 | |
Escambia County | 38309.0 | 37784.0 | |
Etowah County | 104442.0 | 103057.0 | |
Fayette County | 17231.0 | 16759.0 | |
Franklin County | 31734.0 | 31507.0 | |
... | ... | ... | ... |
Wisconsin | Washburn County | 15930.0 | 15552.0 |
Washington County | 133674.0 | 131967.0 | |
Waukesha County | 396488.0 | 390076.0 | |
Waupaca County | 52422.0 | 51945.0 | |
Waushara County | 24581.0 | 24033.0 | |
Winnebago County | 169639.0 | 167059.0 | |
Wood County | 74807.0 | 73435.0 | |
Wyoming | Albany County | 37956.0 | 36428.0 |
Big Horn County | 12022.0 | 11672.0 | |
Campbell County | 49220.0 | 46244.0 | |
Carbon County | 15856.0 | 15559.0 | |
Converse County | 14343.0 | 13728.0 | |
Crook County | 7444.0 | 7114.0 | |
Fremont County | 41129.0 | 40222.0 | |
Goshen County | 13666.0 | 13383.0 | |
Hot Springs County | 4846.0 | 4741.0 | |
Johnson County | 8636.0 | 8552.0 | |
Laramie County | 97121.0 | 92271.0 | |
Lincoln County | 18722.0 | 17943.0 | |
Natrona County | 82178.0 | 75472.0 | |
Niobrara County | 2548.0 | 2475.0 | |
Park County | 29237.0 | 28259.0 | |
Platte County | 8812.0 | 8678.0 | |
Sheridan County | 30020.0 | 29146.0 | |
Sublette County | 10418.0 | 9899.0 | |
Sweetwater County | 45162.0 | 43593.0 | |
Teton County | 23125.0 | 21297.0 | |
Uinta County | 21102.0 | 20822.0 | |
Washakie County | 8545.0 | 8316.0 | |
Weston County | 7234.0 | 7065.0 |
3142 rows × 2 columns
import numpy as np
def min_max(row):
data = row[['POPESTIMATE2010',
'POPESTIMATE2011',
'POPESTIMATE2012',
'POPESTIMATE2013',
'POPESTIMATE2014',
'POPESTIMATE2015']]
row['max'] = np.max(data)
row['min'] = np.min(data)
return row
df.apply(min_max, axis=1)
SUMLEV | REGION | DIVISION | STATE | COUNTY | STNAME | CTYNAME | CENSUS2010POP | ESTIMATESBASE2010 | POPESTIMATE2010 | ... | RDOMESTICMIG2013 | RDOMESTICMIG2014 | RDOMESTICMIG2015 | RNETMIG2011 | RNETMIG2012 | RNETMIG2013 | RNETMIG2014 | RNETMIG2015 | max | min | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 40 | 3 | 6 | 1 | 0 | Alabama | Alabama | 4779736 | 4780127 | 4785161 | ... | 0.381066 | 0.582002 | -0.467369 | 1.030015 | 0.826644 | 1.383282 | 1.724718 | 0.712594 | 4858979 | 4785161 |
1 | 50 | 3 | 6 | 1 | 1 | Alabama | Autauga County | 54571 | 54571 | 54660 | ... | -3.012349 | 2.265971 | -2.530799 | 7.606016 | -2.626146 | -2.722002 | 2.592270 | -2.187333 | 55347 | 54660 |
2 | 50 | 3 | 6 | 1 | 3 | Alabama | Baldwin County | 182265 | 182265 | 183193 | ... | 21.845705 | 19.243287 | 17.197872 | 15.844176 | 18.559627 | 22.727626 | 20.317142 | 18.293499 | 203709 | 183193 |
3 | 50 | 3 | 6 | 1 | 5 | Alabama | Barbour County | 27457 | 27457 | 27341 | ... | -7.056824 | -3.904217 | -10.543299 | -4.874741 | -2.758113 | -7.167664 | -3.978583 | -10.543299 | 27341 | 26489 |
4 | 50 | 3 | 6 | 1 | 7 | Alabama | Bibb County | 22915 | 22919 | 22861 | ... | -6.201001 | -0.177537 | 0.177258 | -5.088389 | -4.363636 | -5.403729 | 0.754533 | 1.107861 | 22861 | 22512 |
5 | 50 | 3 | 6 | 1 | 9 | Alabama | Blount County | 57322 | 57322 | 57373 | ... | -1.748766 | -2.062535 | -1.369970 | 1.859511 | -0.848580 | -1.402476 | -1.577232 | -0.884411 | 57776 | 57373 |
6 | 50 | 3 | 6 | 1 | 11 | Alabama | Bullock County | 10914 | 10915 | 10887 | ... | -1.130263 | 14.354290 | -16.167247 | -29.001673 | -2.825524 | 1.507017 | 17.243790 | -13.193961 | 10887 | 10606 |
7 | 50 | 3 | 6 | 1 | 13 | Alabama | Butler County | 20947 | 20946 | 20944 | ... | -5.655413 | 1.085428 | -6.529805 | -13.936612 | -11.586865 | -5.557058 | 1.184103 | -6.430868 | 20944 | 20154 |
8 | 50 | 3 | 6 | 1 | 15 | Alabama | Calhoun County | 118572 | 118586 | 118437 | ... | -5.524649 | -4.463211 | -3.376322 | -5.791579 | -4.092677 | -5.062836 | -3.912834 | -2.806406 | 118437 | 115620 |
9 | 50 | 3 | 6 | 1 | 17 | Alabama | Chambers County | 34215 | 34170 | 34098 | ... | 2.872721 | -2.287222 | 1.349468 | -1.821092 | 4.701181 | 3.781439 | -1.290228 | 2.346901 | 34153 | 33993 |
10 | 50 | 3 | 6 | 1 | 19 | Alabama | Cherokee County | 25989 | 25986 | 25976 | ... | 5.488706 | -0.076806 | -3.239866 | 6.416167 | 1.420264 | 5.757384 | 0.230419 | -2.931307 | 26084 | 25859 |
11 | 50 | 3 | 6 | 1 | 21 | Alabama | Chilton County | 43643 | 43631 | 43665 | ... | 0.480044 | 0.456017 | -2.253483 | -0.823761 | -2.447504 | 0.868651 | 0.957636 | -1.752709 | 43943 | 43665 |
12 | 50 | 3 | 6 | 1 | 23 | Alabama | Choctaw County | 13859 | 13858 | 13841 | ... | -8.766391 | -1.274984 | -5.291205 | -15.528177 | -0.737028 | -8.766391 | -1.274984 | -5.291205 | 13841 | 13170 |
13 | 50 | 3 | 6 | 1 | 25 | Alabama | Clarke County | 25833 | 25840 | 25767 | ... | -0.318345 | -8.686428 | -5.613667 | -6.077488 | -17.509958 | -0.159172 | -8.486280 | -5.411736 | 25767 | 24675 |
14 | 50 | 3 | 6 | 1 | 27 | Alabama | Clay County | 13932 | 13932 | 13880 | ... | 4.902871 | 5.702648 | 3.912450 | -10.816697 | -13.345130 | 4.977157 | 5.776708 | 3.986270 | 13880 | 13456 |
15 | 50 | 3 | 6 | 1 | 29 | Alabama | Cleburne County | 14972 | 14972 | 14973 | ... | 7.345821 | 3.654485 | -3.123961 | -3.673524 | -5.151880 | 7.345821 | 3.654485 | -3.123961 | 15072 | 14921 |
16 | 50 | 3 | 6 | 1 | 31 | Alabama | Coffee County | 49948 | 49948 | 50177 | ... | -13.146535 | -3.602859 | 2.214774 | 2.166460 | 11.513368 | -10.438741 | -0.767822 | 5.350738 | 51211 | 50177 |
17 | 50 | 3 | 6 | 1 | 33 | Alabama | Colbert County | 54428 | 54428 | 54514 | ... | 1.762390 | 1.835688 | -0.110260 | 0.513964 | 1.469035 | 2.276420 | 2.533249 | 0.588052 | 54514 | 54354 |
18 | 50 | 3 | 6 | 1 | 35 | Alabama | Conecuh County | 13228 | 13228 | 13208 | ... | -6.107224 | -14.645416 | 2.684140 | -4.861559 | -7.504690 | -6.107224 | -14.645416 | 2.684140 | 13208 | 12662 |
19 | 50 | 3 | 6 | 1 | 37 | Alabama | Coosa County | 11539 | 11758 | 11758 | ... | -4.313831 | -22.958017 | -5.387581 | -34.017138 | -10.380162 | -4.403703 | -23.049483 | -5.387581 | 11758 | 10724 |
20 | 50 | 3 | 6 | 1 | 39 | Alabama | Covington County | 37765 | 37765 | 37796 | ... | 0.740271 | 3.697932 | -0.316945 | 6.881460 | -4.559952 | 0.793147 | 3.750759 | -0.264121 | 38060 | 37796 |
21 | 50 | 3 | 6 | 1 | 41 | Alabama | Crenshaw County | 13906 | 13906 | 13853 | ... | -1.864936 | 3.084648 | 3.439504 | 2.666763 | 5.099293 | -0.502098 | 4.734577 | 5.087600 | 13963 | 13853 |
22 | 50 | 3 | 6 | 1 | 43 | Alabama | Cullman County | 80406 | 80410 | 80473 | ... | 4.071247 | 5.087142 | 7.915406 | -1.031427 | -0.634159 | 4.542916 | 5.593387 | 8.417777 | 82005 | 80374 |
23 | 50 | 3 | 6 | 1 | 45 | Alabama | Dale County | 50251 | 50251 | 50358 | ... | -15.236079 | -11.979785 | -5.107706 | -9.575283 | -0.776637 | -12.640155 | -9.503292 | -1.998668 | 50358 | 49501 |
24 | 50 | 3 | 6 | 1 | 47 | Alabama | Dallas County | 43820 | 43820 | 43803 | ... | -16.745678 | -9.344789 | -14.687232 | -15.727573 | -11.378047 | -16.792849 | -9.368689 | -14.711389 | 43803 | 41131 |
25 | 50 | 3 | 6 | 1 | 49 | Alabama | DeKalb County | 71109 | 71115 | 71142 | ... | -1.748807 | 0.267830 | 0.028141 | 1.375159 | -8.656001 | -1.029539 | 1.198187 | 0.956790 | 71387 | 70869 |
26 | 50 | 3 | 6 | 1 | 51 | Alabama | Elmore County | 79303 | 79296 | 79465 | ... | 1.760531 | -1.507057 | 2.067820 | 3.674511 | 1.558176 | 2.306047 | -0.951175 | 2.757093 | 81468 | 79465 |
27 | 50 | 3 | 6 | 1 | 53 | Alabama | Escambia County | 38319 | 38319 | 38309 | ... | -4.822706 | -1.189831 | 1.190902 | -3.397716 | -3.803428 | -4.769999 | -1.136950 | 1.243830 | 38309 | 37784 |
28 | 50 | 3 | 6 | 1 | 55 | Alabama | Etowah County | 104430 | 104427 | 104442 | ... | -1.931884 | -1.726932 | -2.082234 | -0.632554 | 2.446383 | -1.518596 | -1.234901 | -1.588308 | 104442 | 103057 |
29 | 50 | 3 | 6 | 1 | 57 | Alabama | Fayette County | 17241 | 17241 | 17231 | ... | -3.725937 | 0.296745 | -2.797536 | -5.132243 | -0.705426 | -3.785079 | 0.237396 | -2.857058 | 17231 | 16759 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
3163 | 50 | 2 | 3 | 55 | 131 | Wisconsin | Washington County | 131887 | 131885 | 131967 | ... | -2.215465 | 1.601149 | -0.434498 | -0.431504 | 1.162817 | -1.763330 | 2.104796 | 0.059931 | 133674 | 131967 |
3164 | 50 | 2 | 3 | 55 | 133 | Wisconsin | Waukesha County | 389891 | 389938 | 390076 | ... | 0.038132 | 0.760109 | -0.719858 | 0.102448 | 3.180527 | 1.189727 | 2.077633 | 0.593567 | 396488 | 390076 |
3165 | 50 | 2 | 3 | 55 | 135 | Wisconsin | Waupaca County | 52410 | 52410 | 52422 | ... | 6.292687 | -0.441031 | -0.480617 | 3.359933 | -2.011937 | 6.561277 | -0.134227 | -0.173022 | 52422 | 51945 |
3166 | 50 | 2 | 3 | 55 | 137 | Wisconsin | Waushara County | 24496 | 24496 | 24506 | ... | -4.097017 | -4.906711 | -4.397793 | 5.174486 | -2.160399 | -3.810226 | -4.535615 | -4.024395 | 24581 | 24033 |
3167 | 50 | 2 | 3 | 55 | 139 | Wisconsin | Winnebago County | 166994 | 166994 | 167059 | ... | 0.833819 | -2.406192 | -4.557985 | 0.842573 | 3.502335 | 1.531624 | -1.545153 | -3.685304 | 169639 | 167059 |
3168 | 50 | 2 | 3 | 55 | 141 | Wisconsin | Wood County | 74749 | 74749 | 74807 | ... | -6.901200 | -5.596471 | -3.958322 | -3.733590 | -4.562809 | -6.442917 | -5.040889 | -3.414223 | 74807 | 73435 |
3169 | 40 | 4 | 8 | 56 | 0 | Wyoming | Wyoming | 563626 | 563767 | 564516 | ... | 4.487115 | -4.788275 | -3.221091 | 0.289680 | 10.694870 | 5.440390 | -3.727831 | -2.091573 | 586107 | 564516 |
3170 | 50 | 4 | 8 | 56 | 1 | Wyoming | Albany County | 36299 | 36299 | 36428 | ... | -3.544634 | -3.334877 | -9.911169 | 6.736119 | 6.433032 | 0.719587 | 1.429233 | -5.166460 | 37956 | 36428 |
3171 | 50 | 4 | 8 | 56 | 3 | Wyoming | Big Horn County | 11668 | 11668 | 11672 | ... | 16.815908 | -8.026420 | 5.095861 | 4.868258 | 3.144921 | 17.236306 | -7.608378 | 5.513554 | 12022 | 11672 |
3172 | 50 | 4 | 8 | 56 | 5 | Wyoming | Campbell County | 46133 | 46133 | 46244 | ... | -5.895711 | -8.550911 | 10.916963 | -2.649606 | 15.558684 | -5.916543 | -8.509402 | 10.978525 | 49220 | 46244 |
3173 | 50 | 4 | 8 | 56 | 7 | Wyoming | Carbon County | 15885 | 15885 | 15837 | ... | 3.178134 | -2.970641 | -23.300971 | -7.392431 | -12.636926 | 3.623073 | -2.338590 | -22.600668 | 15856 | 15559 |
3174 | 50 | 4 | 8 | 56 | 9 | Wyoming | Converse County | 13833 | 13833 | 13826 | ... | 19.035533 | -20.550587 | -0.070403 | -12.774915 | 16.502720 | 20.093063 | -19.358233 | 1.126443 | 14343 | 13728 |
3175 | 50 | 4 | 8 | 56 | 11 | Wyoming | Crook County | 7083 | 7083 | 7114 | ... | 1.397819 | 6.378258 | 18.629317 | -0.982939 | -3.642222 | 2.096729 | 7.071547 | 19.309219 | 7444 | 7114 |
3176 | 50 | 4 | 8 | 56 | 13 | Wyoming | Fremont County | 40123 | 40123 | 40222 | ... | -4.990688 | -12.331633 | -13.673610 | 3.093562 | 8.027411 | -4.747240 | -12.013555 | -13.352750 | 41129 | 40222 |
3177 | 50 | 4 | 8 | 56 | 15 | Wyoming | Goshen County | 13249 | 13247 | 13408 | ... | -8.079028 | -7.017803 | -11.899450 | 14.886132 | 4.841727 | -6.903896 | -5.761986 | -10.635133 | 13666 | 13383 |
3178 | 50 | 4 | 8 | 56 | 17 | Wyoming | Hot Springs County | 4812 | 4812 | 4813 | ... | 3.095336 | -6.017222 | -5.454164 | 5.191569 | 6.001656 | 2.888981 | -6.224712 | -5.663940 | 4846 | 4741 |
3179 | 50 | 4 | 8 | 56 | 19 | Wyoming | Johnson County | 8569 | 8569 | 8581 | ... | -0.812583 | -10.715742 | 0.933652 | 5.227392 | -4.058912 | -0.812583 | -10.715742 | 0.933652 | 8636 | 8552 |
3180 | 50 | 4 | 8 | 56 | 21 | Wyoming | Laramie County | 91738 | 91881 | 92271 | ... | 4.787847 | -1.226133 | 0.278940 | -0.973320 | 17.914554 | 6.003143 | -0.207819 | 1.673640 | 97121 | 92271 |
3181 | 50 | 4 | 8 | 56 | 23 | Wyoming | Lincoln County | 18106 | 18106 | 18091 | ... | 13.564556 | 6.125989 | 1.555544 | -9.691801 | -11.566801 | 13.619696 | 6.234414 | 1.662823 | 18722 | 17943 |
3182 | 50 | 4 | 8 | 56 | 25 | Wyoming | Natrona County | 75450 | 75450 | 75472 | ... | 24.322042 | -0.958472 | -0.061057 | 7.689674 | 23.749508 | 25.085233 | -0.110593 | 0.793743 | 82178 | 75472 |
3183 | 50 | 4 | 8 | 56 | 27 | Wyoming | Niobrara County | 2484 | 2484 | 2492 | ... | 29.066295 | -12.603387 | 7.492114 | -0.401849 | 0.806452 | 29.066295 | -12.603387 | 7.492114 | 2548 | 2475 |
3184 | 50 | 4 | 8 | 56 | 29 | Wyoming | Park County | 28205 | 28205 | 28259 | ... | 7.641997 | -9.252437 | -2.878980 | 6.486639 | 11.127389 | 10.877797 | -5.585731 | 0.856839 | 29237 | 28259 |
3185 | 50 | 4 | 8 | 56 | 31 | Wyoming | Platte County | 8667 | 8667 | 8678 | ... | 2.634593 | 6.055759 | 4.662270 | 4.373094 | 4.933173 | 2.176403 | 5.598720 | 4.207414 | 8812 | 8678 |
3186 | 50 | 4 | 8 | 56 | 33 | Wyoming | Sheridan County | 29116 | 29116 | 29146 | ... | 4.546373 | 3.678069 | -3.298406 | 2.122524 | 9.342778 | 5.523001 | 4.781489 | -2.198937 | 30020 | 29146 |
3187 | 50 | 4 | 8 | 56 | 35 | Wyoming | Sublette County | 10247 | 10247 | 10244 | ... | -40.870074 | -16.596273 | -22.870900 | -21.092907 | 16.828794 | -39.211861 | -14.409938 | -20.664059 | 10418 | 9899 |
3188 | 50 | 4 | 8 | 56 | 37 | Wyoming | Sweetwater County | 43806 | 43806 | 43593 | ... | -5.339774 | -14.252889 | -14.248864 | 1.255221 | 16.243199 | -5.295460 | -14.075283 | -14.070195 | 45162 | 43593 |
3189 | 50 | 4 | 8 | 56 | 39 | Wyoming | Teton County | 21294 | 21294 | 21297 | ... | 19.525929 | 14.143021 | -0.564849 | 0.654527 | 2.408578 | 21.160658 | 16.308671 | 1.520747 | 23125 | 21297 |
3190 | 50 | 4 | 8 | 56 | 41 | Wyoming | Uinta County | 21118 | 21118 | 21102 | ... | -6.902954 | -14.215862 | -12.127022 | -18.136812 | -5.536861 | -7.521840 | -14.740608 | -12.606351 | 21102 | 20822 |
3191 | 50 | 4 | 8 | 56 | 43 | Wyoming | Washakie County | 8533 | 8533 | 8545 | ... | -2.013502 | -17.781491 | 1.682288 | -11.990126 | -1.182592 | -2.250385 | -18.020168 | 1.441961 | 8545 | 8316 |
3192 | 50 | 4 | 8 | 56 | 45 | Wyoming | Weston County | 7208 | 7208 | 7181 | ... | 12.372583 | 1.533635 | 6.935294 | -12.032179 | -8.040059 | 12.372583 | 1.533635 | 6.935294 | 7234 | 7065 |
3193 rows × 102 columns
rows = ['POPESTIMATE2010',
'POPESTIMATE2011',
'POPESTIMATE2012',
'POPESTIMATE2013',
'POPESTIMATE2014',
'POPESTIMATE2015']
df.apply(lambda x: np.max(x[rows]), axis=1)
0 4858979 1 55347 2 203709 3 27341 4 22861 5 57776 6 10887 7 20944 8 118437 9 34153 10 26084 11 43943 12 13841 13 25767 14 13880 15 15072 16 51211 17 54514 18 13208 19 11758 20 38060 21 13963 22 82005 23 50358 24 43803 25 71387 26 81468 27 38309 28 104442 29 17231 ... 3163 133674 3164 396488 3165 52422 3166 24581 3167 169639 3168 74807 3169 586107 3170 37956 3171 12022 3172 49220 3173 15856 3174 14343 3175 7444 3176 41129 3177 13666 3178 4846 3179 8636 3180 97121 3181 18722 3182 82178 3183 2548 3184 29237 3185 8812 3186 30020 3187 10418 3188 45162 3189 23125 3190 21102 3191 8545 3192 7234 Length: 3193, dtype: int64
import pandas as pd
import numpy as np
df = pd.read_csv('census.csv')
df = df[df['SUMLEV']==50]
df
%%timeit -n 10
for state in df['STNAME'].unique():
avg = np.average(df.where(df['STNAME']==state).dropna()['CENSUS2010POP'])
print('Counties in state ' + state + ' have an average population of ' + str(avg))
%%timeit -n 10
for group, frame in df.groupby('STNAME'):
avg = np.average(frame['CENSUS2010POP'])
print('Counties in state ' + group + ' have an average population of ' + str(avg))
df.head()
df = df.set_index('STNAME')
def fun(item):
if item[0]<'M':
return 0
if item[0]<'Q':
return 1
return 2
for group, frame in df.groupby(fun):
print('There are ' + str(len(frame)) + ' records in group ' + str(group) + ' for processing.')
df = pd.read_csv('census.csv')
df = df[df['SUMLEV']==50]
df.groupby('STNAME').agg({'CENSUS2010POP': np.average})
print(type(df.groupby(level=0)['POPESTIMATE2010','POPESTIMATE2011']))
print(type(df.groupby(level=0)['POPESTIMATE2010']))
(df.set_index('STNAME').groupby(level=0)['CENSUS2010POP']
.agg({'avg': np.average, 'sum': np.sum}))
(df.set_index('STNAME').groupby(level=0)['POPESTIMATE2010','POPESTIMATE2011']
.agg({'avg': np.average, 'sum': np.sum}))
(df.set_index('STNAME').groupby(level=0)['POPESTIMATE2010','POPESTIMATE2011']
.agg({'POPESTIMATE2010': np.average, 'POPESTIMATE2011': np.sum}))
df = pd.DataFrame(['A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+', 'D'],
index=['excellent', 'excellent', 'excellent', 'good', 'good', 'good', 'ok', 'ok', 'ok', 'poor', 'poor'])
df.rename(columns={0: 'Grades'}, inplace=True)
df
df['Grades'].astype('category').head()
grades = df['Grades'].astype('category',
categories=['D', 'D+', 'C-', 'C', 'C+', 'B-', 'B', 'B+', 'A-', 'A', 'A+'],
ordered=True)
grades.head()
grades > 'C'
df = pd.read_csv('census.csv')
df = df[df['SUMLEV']==50]
df = df.set_index('STNAME').groupby(level=0)['CENSUS2010POP'].agg({'avg': np.average})
pd.cut(df['avg'],10)
#http://open.canada.ca/data/en/dataset/98f1a129-f628-4ce4-b24d-6f16bf24dd64
df = pd.read_csv('cars.csv')
df.head()
df.pivot_table(values='(kW)', index='YEAR', columns='Make', aggfunc=np.mean)
df.pivot_table(values='(kW)', index='YEAR', columns='Make', aggfunc=[np.mean,np.min], margins=True)
import pandas as pd
import numpy as np
pd.Timestamp('9/1/2016 10:05AM')
Timestamp('2016-09-01 10:05:00')
pd.Period('1/2016')
Period('2016-01', 'M')
pd.Period('3/5/2016')
Period('2016-03-05', 'D')
t1 = pd.Series(list('abc'), [pd.Timestamp('2016-09-01'), pd.Timestamp('2016-09-02'), pd.Timestamp('2016-09-03')])
t1
2016-09-01 a 2016-09-02 b 2016-09-03 c dtype: object
type(t1.index)
pandas.tseries.index.DatetimeIndex
t2 = pd.Series(list('def'), [pd.Period('2016-09'), pd.Period('2016-10'), pd.Period('2016-11')])
t2
2016-09 d 2016-10 e 2016-11 f Freq: M, dtype: object
type(t2.index)
pandas.tseries.period.PeriodIndex
d1 = ['2 June 2013', 'Aug 29, 2014', '2015-06-26', '7/12/16']
ts3 = pd.DataFrame(np.random.randint(10, 100, (4,2)), index=d1, columns=list('ab'))
ts3
a | b | |
---|---|---|
2 June 2013 | 16 | 46 |
Aug 29, 2014 | 14 | 66 |
2015-06-26 | 59 | 99 |
7/12/16 | 27 | 17 |
ts3.index = pd.to_datetime(ts3.index)
ts3
a | b | |
---|---|---|
2013-06-02 | 16 | 46 |
2014-08-29 | 14 | 66 |
2015-06-26 | 59 | 99 |
2016-07-12 | 27 | 17 |
pd.to_datetime('4.7.12', dayfirst=True)
Timestamp('2012-07-04 00:00:00')
pd.Timestamp('9/3/2016')-pd.Timestamp('9/1/2016')
Timedelta('2 days 00:00:00')
pd.Timestamp('9/2/2016 8:10AM') + pd.Timedelta('12D 3H')
Timestamp('2016-09-14 11:10:00')
dates = pd.date_range('10-01-2016', periods=9, freq='2W-SUN')
dates
DatetimeIndex(['2016-10-02', '2016-10-16', '2016-10-30', '2016-11-13', '2016-11-27', '2016-12-11', '2016-12-25', '2017-01-08', '2017-01-22'], dtype='datetime64[ns]', freq='2W-SUN')
df = pd.DataFrame({'Count 1': 100 + np.random.randint(-5, 10, 9).cumsum(),
'Count 2': 120 + np.random.randint(-5, 10, 9)}, index=dates)
df
Count 1 | Count 2 | |
---|---|---|
2016-10-02 | 104 | 125 |
2016-10-16 | 109 | 122 |
2016-10-30 | 111 | 127 |
2016-11-13 | 117 | 126 |
2016-11-27 | 114 | 126 |
2016-12-11 | 109 | 121 |
2016-12-25 | 105 | 126 |
2017-01-08 | 105 | 125 |
2017-01-22 | 101 | 123 |
df.index.weekday_name
array(['Sunday', 'Sunday', 'Sunday', 'Sunday', 'Sunday', 'Sunday', 'Sunday', 'Sunday', 'Sunday'], dtype=object)
df.diff()
Count 1 | Count 2 | |
---|---|---|
2016-10-02 | NaN | NaN |
2016-10-16 | 5.0 | -3.0 |
2016-10-30 | 2.0 | 5.0 |
2016-11-13 | 6.0 | -1.0 |
2016-11-27 | -3.0 | 0.0 |
2016-12-11 | -5.0 | -5.0 |
2016-12-25 | -4.0 | 5.0 |
2017-01-08 | 0.0 | -1.0 |
2017-01-22 | -4.0 | -2.0 |
df.resample('M').mean()
Count 1 | Count 2 | |
---|---|---|
2016-10-31 | 108.0 | 124.666667 |
2016-11-30 | 115.5 | 126.000000 |
2016-12-31 | 107.0 | 123.500000 |
2017-01-31 | 103.0 | 124.000000 |
df['2017']
Count 1 | Count 2 | |
---|---|---|
2017-01-08 | 105 | 125 |
2017-01-22 | 101 | 123 |
df['2016-12']
Count 1 | Count 2 | |
---|---|---|
2016-12-11 | 109 | 121 |
2016-12-25 | 105 | 126 |
df['2016-12':]
Count 1 | Count 2 | |
---|---|---|
2016-12-11 | 109 | 121 |
2016-12-25 | 105 | 126 |
2017-01-08 | 105 | 125 |
2017-01-22 | 101 | 123 |
df.asfreq('W', method='ffill')
import matplotlib.pyplot as plt
%matplotlib inline
df.plot()