From de4e8803b2d5e1d26d00db930a73c56f51b487bd Mon Sep 17 00:00:00 2001 From: Sortofamudkip <wishyutp0328@gmail.com> Date: Thu, 13 Jul 2023 00:31:52 +0200 Subject: [PATCH] colname in columns check (get_category_counts) --- src/Dataset.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Dataset.py b/src/Dataset.py index 52024c9..a192474 100644 --- a/src/Dataset.py +++ b/src/Dataset.py @@ -270,6 +270,10 @@ class Dataset: if type(colname) != str: logging.error("parameter `colname` is not a string") raise ValueError(f"{colname} is not a string") + if colname not in self.dataframe.columns: + logging.error("column requested not in dataframe") + raise KeyError(f"{colname} is not a column in dataframe") + if not (ascending is None or type(ascending) is bool): logging.error("parameter `ascending` is not a bool or None") raise ValueError(f"{ascending} is not a bool or None") -- GitLab