47
47
OptionalDependency ,
48
48
)
49
49
50
+ NATURAL_EARTH_DATASET = "naturalearth_lowres"
50
51
51
52
class PandasDataset (object ):
52
53
"""
53
54
This class provides APIs that can work on a sampled dataset.
54
55
"""
55
56
56
- @runtime_dependency (module = "geopandas" , install_from = OptionalDependency .GEO )
57
57
def __init__ (
58
58
self ,
59
59
sampled_df ,
@@ -67,9 +67,7 @@ def __init__(
67
67
self .correlation = None
68
68
self .feature_dist_html_dict = {}
69
69
self .feature_types = metadata if metadata is not None else {}
70
- self .world = geopandas .read_file (
71
- geopandas .datasets .get_path ("naturalearth_lowres" )
72
- )
70
+ self .world = None
73
71
74
72
self .numeric_columns = self .sampled_df .select_dtypes (
75
73
utils .numeric_pandas_dtypes ()
@@ -562,7 +560,7 @@ def plot_gis_scatter(self, lon="longitude", lat="latitude", ax=None):
562
560
),
563
561
)
564
562
world = geopandas .read_file (
565
- geopandas .datasets .get_path ("naturalearth_lowres" )
563
+ geopandas .datasets .get_path (NATURAL_EARTH_DATASET )
566
564
)
567
565
ax1 = world .plot (ax = ax , color = "lightgrey" , linewidth = 0.5 , edgecolor = "white" )
568
566
gdf .plot (ax = ax1 , color = "blue" , markersize = 10 )
@@ -706,6 +704,12 @@ def _visualize_feature_distribution(self, html_widget):
706
704
gdf = geopandas .GeoDataFrame (
707
705
df , geometry = geopandas .points_from_xy (df ["lon" ], df ["lat" ])
708
706
)
707
+
708
+ if not self .world :
709
+ self .world = geopandas .read_file (
710
+ geopandas .datasets .get_path (NATURAL_EARTH_DATASET )
711
+ )
712
+
709
713
self .world .plot (
710
714
ax = ax , color = "lightgrey" , linewidth = 0.5 , edgecolor = "white"
711
715
)
0 commit comments