21
21
class GeoMaps :
22
22
"""Class to map counties to other geographic resolutions."""
23
23
24
- def __init__ (self , geo_filepath ):
25
- self .geo_filepath = geo_filepath
24
+ def __init__ (self ):
26
25
self .gmpr = GeoMapper ()
27
26
28
27
@staticmethod
@@ -38,13 +37,6 @@ def county_to_msa(self, data):
38
37
39
38
Returns: tuple of dataframe at the daily-msa resolution, and the geo_id column name
40
39
"""
41
- msa_map = pd .read_csv (
42
- join (self .geo_filepath , "02_20_uszips.csv" ),
43
- usecols = ["fips" , "cbsa_id" ],
44
- dtype = {"cbsa_id" : float },
45
- converters = {"fips" : GeoMaps .convert_fips },
46
- )
47
- msa_map .drop_duplicates (inplace = True )
48
40
data = self .gmpr .add_geocode (data ,
49
41
"fips" ,
50
42
"msa" ,
@@ -63,14 +55,6 @@ def county_to_state(self, data):
63
55
64
56
Returns: tuple of dataframe at the daily-state resolution, and geo_id column name
65
57
"""
66
-
67
- state_map = pd .read_csv (
68
- join (self .geo_filepath , "02_20_uszips.csv" ),
69
- usecols = ["fips" , "state_id" ],
70
- dtype = {"state_id" : str },
71
- converters = {"fips" : GeoMaps .convert_fips },
72
- )
73
- state_map .drop_duplicates (inplace = True )
74
58
data = self .gmpr .add_geocode (data ,
75
59
"fips" ,
76
60
"state_id" ,
@@ -94,21 +78,6 @@ def county_to_hrr(self, data):
94
78
tuple of (data frame at daily-HRR resolution, geo_id column name)
95
79
96
80
"""
97
-
98
- hrr_map = pd .read_csv (
99
- join (self .geo_filepath , "transfipsToHRR.csv" ),
100
- converters = {"fips" : GeoMaps .convert_fips },
101
- )
102
-
103
- ## Each row is one FIPS. Columns [3:] are HRR numbers, consecutively.
104
- ## Entries are the proportion of the county contained in the HRR, so rows
105
- ## sum to 1.
106
-
107
- ## Drop county and state names -- not needed here.
108
- hrr_map .drop (columns = ["county_name" , "state_id" ], inplace = True )
109
-
110
- hrr_map = hrr_map .melt (["fips" ], var_name = "hrr" , value_name = "wpop" )
111
- hrr_map = hrr_map [hrr_map ["wpop" ] > 0 ]
112
81
data = self .gmpr .add_geocode (data ,
113
82
"fips" ,
114
83
"hrr" ,
0 commit comments