3
3
Authors: Dmitry Shemetov @dshemetov, James Sharpnack @jsharpna, Maria Jahja
4
4
"""
5
5
6
- from os .path import join
7
6
from collections import defaultdict
7
+ from os .path import join
8
8
from typing import Iterator , List , Literal , Optional , Set , Union
9
9
10
+ import importlib_resources
10
11
import pandas as pd
11
- import pkg_resources
12
12
from pandas .api .types import is_string_dtype
13
13
14
14
@@ -153,7 +153,7 @@ def __init__(self, census_year: int = 2020):
153
153
for from_code , to_codes in self .CROSSWALK_FILENAMES .items ():
154
154
for to_code , file_path in to_codes .items ():
155
155
self ._crosswalks [from_code ][to_code ] = self ._load_crosswalk_from_file (
156
- from_code , to_code , join (f "data/ { census_year } " , file_path )
156
+ from_code , to_code , join ("data" , f" { census_year } " , file_path )
157
157
)
158
158
159
159
for geo_type in self ._geos :
@@ -162,7 +162,7 @@ def __init__(self, census_year: int = 2020):
162
162
def _load_crosswalk_from_file (
163
163
self , from_code : str , to_code : str , data_path : str
164
164
) -> pd .DataFrame :
165
- stream = pkg_resources . resource_stream (__name__ , data_path )
165
+ stream = importlib_resources . files (__name__ ) / data_path
166
166
dtype = {
167
167
from_code : str ,
168
168
to_code : str ,
0 commit comments