From bcf3b49ce4e5dd4c842fbc710fa0c5cd33778d38 Mon Sep 17 00:00:00 2001 From: Jan Cap Date: Sat, 16 Dec 2023 21:03:31 +0100 Subject: [PATCH] feat: add support for python 3.8 --- src/ydata_profiling/model/alerts.py | 2 +- src/ydata_profiling/model/describe.py | 2 +- .../model/pandas/correlations_pandas.py | 14 +++++++------- src/ydata_profiling/model/pandas/summary_pandas.py | 4 ++-- src/ydata_profiling/model/pandas/table_pandas.py | 3 ++- src/ydata_profiling/model/summary.py | 4 ++-- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/ydata_profiling/model/alerts.py b/src/ydata_profiling/model/alerts.py index 9ce40522a..d32c8cb94 100644 --- a/src/ydata_profiling/model/alerts.py +++ b/src/ydata_profiling/model/alerts.py @@ -698,7 +698,7 @@ def check_correlation_alerts(config: Settings, correlations: dict) -> List[Alert def get_alerts( config: Settings, table_stats: dict, - series_description: dict[str, VarDescription], + series_description: Dict[str, VarDescription], correlations: dict, ) -> List[Alert]: alerts: List[Alert] = check_table_alerts(table_stats) diff --git a/src/ydata_profiling/model/describe.py b/src/ydata_profiling/model/describe.py index a8bfcac1a..9a2ad1619 100644 --- a/src/ydata_profiling/model/describe.py +++ b/src/ydata_profiling/model/describe.py @@ -73,7 +73,7 @@ def describe( # Variable-specific pbar.total += len(df.columns) - series_description: dict[str, VarDescription] = get_series_descriptions( + series_description: Dict[str, VarDescription] = get_series_descriptions( config, df, summarizer, typeset, pbar ) diff --git a/src/ydata_profiling/model/pandas/correlations_pandas.py b/src/ydata_profiling/model/pandas/correlations_pandas.py index a679f9d31..7793b566e 100644 --- a/src/ydata_profiling/model/pandas/correlations_pandas.py +++ b/src/ydata_profiling/model/pandas/correlations_pandas.py @@ -2,7 +2,7 @@ import itertools import warnings -from typing import Callable, Optional +from typing import Callable, Dict, Optional import numpy as np import pandas as pd @@ -86,9 +86,9 @@ def _pairwise_cramers(col_1: pd.Series, col_2: pd.Series) -> float: return _cramers_corrected_stat(pd.crosstab(col_1, col_2), correction=True) -@Cramers.compute.register(Settings, pd.DataFrame, dict[str, VarDescription]) +@Cramers.compute.register(Settings, pd.DataFrame, Dict[str, VarDescription]) def pandas_cramers_compute( - config: Settings, df: pd.DataFrame, summary: dict[str, VarDescription] + config: Settings, df: pd.DataFrame, summary: Dict[str, VarDescription] ) -> Optional[pd.DataFrame]: threshold = config.categorical_maximum_correlation_distinct @@ -127,9 +127,9 @@ def pandas_cramers_compute( return correlation_matrix -@PhiK.compute.register(Settings, pd.DataFrame, dict[str, VarDescription]) +@PhiK.compute.register(Settings, pd.DataFrame, Dict[str, VarDescription]) def pandas_phik_compute( - config: Settings, df: pd.DataFrame, summary: dict[str, VarDescription] + config: Settings, df: pd.DataFrame, summary: Dict[str, VarDescription] ) -> Optional[pd.DataFrame]: df_cols_dict = {i: list(df.columns).index(i) for i in df.columns} @@ -163,9 +163,9 @@ def pandas_phik_compute( return correlation -@Auto.compute.register(Settings, pd.DataFrame, dict[str, VarDescription]) +@Auto.compute.register(Settings, pd.DataFrame, Dict[str, VarDescription]) def pandas_auto_compute( - config: Settings, df: pd.DataFrame, summary: dict[str, VarDescription] + config: Settings, df: pd.DataFrame, summary: Dict[str, VarDescription] ) -> Optional[pd.DataFrame]: threshold = config.categorical_maximum_correlation_distinct numerical_columns = [ diff --git a/src/ydata_profiling/model/pandas/summary_pandas.py b/src/ydata_profiling/model/pandas/summary_pandas.py index d66906caa..190a9250c 100644 --- a/src/ydata_profiling/model/pandas/summary_pandas.py +++ b/src/ydata_profiling/model/pandas/summary_pandas.py @@ -2,7 +2,7 @@ import multiprocessing import multiprocessing.pool -from typing import Tuple +from typing import Dict, Tuple import numpy as np import pandas as pd @@ -65,7 +65,7 @@ def pandas_get_series_descriptions( summarizer: BaseSummarizer, typeset: VisionsTypeset, pbar: tqdm, -) -> dict[str, VarDescription]: +) -> Dict[str, VarDescription]: def multiprocess_1d(args: tuple) -> Tuple[str, VarDescription]: """Wrapper to process series in parallel. diff --git a/src/ydata_profiling/model/pandas/table_pandas.py b/src/ydata_profiling/model/pandas/table_pandas.py index bef531e2f..9198fb0e0 100644 --- a/src/ydata_profiling/model/pandas/table_pandas.py +++ b/src/ydata_profiling/model/pandas/table_pandas.py @@ -1,4 +1,5 @@ from collections import Counter +from typing import Dict import pandas as pd @@ -9,7 +10,7 @@ @get_table_stats.register def pandas_get_table_stats( - config: Settings, df: pd.DataFrame, variable_stats: dict[str, VarDescription] + config: Settings, df: pd.DataFrame, variable_stats: Dict[str, VarDescription] ) -> dict: """General statistics for the DataFrame. diff --git a/src/ydata_profiling/model/summary.py b/src/ydata_profiling/model/summary.py index 8e4179598..e1c0588e2 100644 --- a/src/ydata_profiling/model/summary.py +++ b/src/ydata_profiling/model/summary.py @@ -1,6 +1,6 @@ """Compute statistical description of datasets.""" -from typing import Any +from typing import Any, Dict from multimethod import multimethod from tqdm import tqdm @@ -28,5 +28,5 @@ def get_series_descriptions( summarizer: BaseSummarizer, typeset: VisionsTypeset, pbar: tqdm, -) -> dict[str, VarDescription]: +) -> Dict[str, VarDescription]: raise NotImplementedError()