Skip to content

Commit 3a3c40d

Browse files
committed
Replace deprecated pkg_resources with importlib.resources for resource loading
1 parent 43a2f2b commit 3a3c40d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

datascience/maps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas
1111
import numpy as np
1212
import matplotlib as mpl
13-
import pkg_resources
13+
import importlib.resources
1414
import branca.colormap as cm
1515

1616
import abc
@@ -935,7 +935,8 @@ def get_coordinates(table, replace_columns=False, remove_nans=False):
935935
Table with latitude and longitude coordinates
936936
"""
937937
assert "zip code" in table.labels or (("city" in table.labels or "county" in table.labels) and "state" in table.labels)
938-
ref = Table.read_table(pkg_resources.resource_filename(__name__, "geodata/geocode_states.csv"))
938+
with importlib.resources.files(__package__).joinpath("geodata/geocode_states.csv").open("r", encoding="utf-8") as f:
939+
ref = Table.read_table(f)
939940

940941
index_name = "".join(table.labels) # Ensures that index can't possibly be one of the preexisting columns
941942
index_name += " "

0 commit comments

Comments
 (0)