From a522ed0ef37b6dea0cee5d3ef5498163e30b1761 Mon Sep 17 00:00:00 2001 From: Thomas Bury Date: Sat, 23 Sep 2023 14:57:05 +0200 Subject: [PATCH] fix: :bug: fix missing imports --- src/geomapviz/aggregator.py | 12 ++++-------- src/geomapviz/plot.py | 1 - src/geomapviz/shapefiles.py | 4 +--- src/geomapviz/utils.py | 3 +-- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/geomapviz/aggregator.py b/src/geomapviz/aggregator.py index a83c9a4..37c0aff 100644 --- a/src/geomapviz/aggregator.py +++ b/src/geomapviz/aggregator.py @@ -1,5 +1,6 @@ import numpy as np import pandas as pd +import warnings import geopandas as gpd from typing import Optional, Union, Tuple, List, Dict, Literal from pandas.api.types import is_numeric_dtype @@ -28,16 +29,11 @@ def encode_categorical_columns(df: pd.DataFrame) -> pd.DataFrame: >>> import pandas as pd >>> from typing import List >>> df = pd.DataFrame({'A': pd.Categorical(['a', 'b', 'c', 'a'], categories=['a', 'b', 'c']), - 'B': pd.Categorical(['b', 'a', 'b', 'c'], categories=['a', 'b', 'c']), - 'C': [1, 2, 3, 4], - 'D': [5, 6, 7, 8]}) + >>> 'B': pd.Categorical(['b', 'a', 'b', 'c'], categories=['a', 'b', 'c']), + >>> 'C': [1, 2, 3, 4], + >>> 'D': [5, 6, 7, 8]}) >>> encoded_df = encode_categorical_columns(df) >>> print(encoded_df) - A B C D - 0 0 1 1 5 - 1 1 0 2 6 - 2 2 1 3 7 - 3 0 2 4 8 """ cat_cols = df.select_dtypes("category").columns.tolist() if cat_cols: diff --git a/src/geomapviz/plot.py b/src/geomapviz/plot.py index 1d00b4c..3fc5995 100644 --- a/src/geomapviz/plot.py +++ b/src/geomapviz/plot.py @@ -3,7 +3,6 @@ """ # Settings and libraries from __future__ import print_function -from os.path import dirname, join from mpl_toolkits.axes_grid1 import make_axes_locatable from typing import Optional, Union, Tuple, List, Dict diff --git a/src/geomapviz/shapefiles.py b/src/geomapviz/shapefiles.py index b54f7b0..581de16 100644 --- a/src/geomapviz/shapefiles.py +++ b/src/geomapviz/shapefiles.py @@ -1,10 +1,8 @@ # Settings and libraries from __future__ import print_function -from os.path import dirname, join -from pkg_resources import resource_stream, resource_filename +from pkg_resources import resource_filename from cartopy import crs # pandas -import pandas as pd import geopandas as gpd diff --git a/src/geomapviz/utils.py b/src/geomapviz/utils.py index 8c75e50..73cef92 100644 --- a/src/geomapviz/utils.py +++ b/src/geomapviz/utils.py @@ -1,8 +1,7 @@ # Settings and libraries from __future__ import print_function -import numpy as np import pandas as pd -from typing import Union, Optional, Tuple, List +from typing import List def check_list_of_str(str_list: List[str], name: str = "str_list") -> None: