From 925ac985c5f4a1ceed5f43e3e28b092b3ab29837 Mon Sep 17 00:00:00 2001 From: Andreas Kanz Date: Fri, 23 Sep 2022 09:34:07 +0200 Subject: [PATCH] linting + simplify --- src/klib/describe.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/klib/describe.py b/src/klib/describe.py index 8d95d6b..970c12f 100644 --- a/src/klib/describe.py +++ b/src/klib/describe.py @@ -15,6 +15,10 @@ import pandas as pd import scipy import seaborn as sns +from matplotlib import ticker +from matplotlib.colors import LinearSegmentedColormap +from matplotlib.colors import to_rgb + from klib.utils import _corr_selector from klib.utils import _missing_vals from klib.utils import _validate_input_bool @@ -23,9 +27,6 @@ from klib.utils import _validate_input_range from klib.utils import _validate_input_smaller from klib.utils import _validate_input_sum_larger -from matplotlib import ticker -from matplotlib.colors import LinearSegmentedColormap -from matplotlib.colors import to_rgb __all__ = ["cat_plot", "corr_mat", "corr_plot", "dist_plot", "missingval_plot"] @@ -93,12 +94,12 @@ def cat_plot( if n_unique < top + bottom: if bottom > top: - lim_top = int(n_unique // 2) if int(n_unique // 2) < top else top + lim_top = min(int(n_unique // 2), top) lim_bot = n_unique - lim_top else: - lim_bot = int(n_unique // 2) if int(n_unique // 2) < bottom else bottom + lim_bot = min(int(n_unique // 2), bottom) lim_top = n_unique - lim_bot - + value_counts_top = value_counts[:lim_top] value_counts_idx_top = value_counts_top.index.tolist() value_counts_bot = value_counts[-lim_bot:] if lim_bot > 0 else pd.DataFrame()