Skip to content
Snippets Groups Projects
Commit 7a3ca6f5 authored by Sortofamudkip's avatar Sortofamudkip
Browse files

param checking in treat_outliers

parent 267a608f
No related branches found
No related tags found
No related merge requests found
......@@ -160,7 +160,26 @@ class Dataset:
is_competitive_col = self.get_is_competitive_col(dataframe)
return is_competitive_col
def treat_outliers(self, df, colname) -> pd.DataFrame:
def treat_outliers(self, df: pd.DataFrame, colname: str) -> pd.DataFrame:
"""Treat outliers of numerical columns.
Args:
df (pd.DataFrame): the dataframe.
colname (str): the column name to treat.
Returns:
pd.DataFrame: the filtered dataframe.
"""
if type(df) != pd.DataFrame:
logging.error("parameter `dataframe` is not a pandas DataFrame")
raise ValueError(f"{df} is not a pandas DataFrame")
if type(colname) != str:
logging.error("parameter `colname` is not a string")
raise ValueError(f"{colname} is not a string")
if colname not in df.columns:
logging.error("column requested not in dataframe")
raise KeyError(f"{colname} is not a column in dataframe")
q = df[colname].quantile(0.99)
return df[df[colname] < q]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment