@@ -357,6 +357,18 @@ def test_outlier_identifier():
357357 }
358358 )
359359
360+ numeric_only_df = pd .DataFrame ({
361+ 'SepalLengthCm' : [5.1 , 4.9 , 4.7 , 5.5 , 5.1 , 50 , 5.4 , 5.0 , 5.2 , 5.3 , 5.1 ],
362+ 'SepalWidthCm' : [1.4 , 1.4 , 20 , 2.0 , 0.7 , 1.6 , 1.2 , 1.4 , 1.8 , 1.5 , 2.1 ],
363+ 'PetalWidthCm' : [0.2 , 0.2 , 0.2 , 0.3 , 0.4 , 0.5 , 0.5 , 0.6 , 0.4 , 0.2 , 5 ]
364+ })
365+
366+ numeric_only_out = pd .DataFrame ({
367+ 'SepalLengthCm' : [5.1 , 4.9 , 5.5 , 5.1 , 5.4 , 5.0 , 5.2 , 5.3 ],
368+ 'SepalWidthCm' : [1.4 , 1.4 , 2.0 , 0.7 , 1.2 , 1.4 , 1.8 , 1.5 ],
369+ 'PetalWidthCm' :[0.2 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.4 , 0.2 ],
370+ })
371+
360372 # Test if the imput is not dataFrame
361373 with raises (TypeError ):
362374 eda_utils_py .outlier_identifier ("not dataframe" )
@@ -369,6 +381,10 @@ def test_outlier_identifier():
369381 with raises (Exception ):
370382 eda_utils_py .outlier_identifier (test_df , columns = ["not in" ])
371383
384+ # Test if dataframe contains non-numeric column, but the user want to do it for all columns.
385+ with raises (Exception ):
386+ eda_utils_py .outlier_identifier (test_df , method = "trim" )
387+
372388 # Test if method input is not one of three methods provided
373389 with raises (Exception ):
374390 eda_utils_py .outlier_identifier (test_df , columns = ["SepalLengthCm" ], method = "no" )
@@ -394,3 +410,6 @@ def test_outlier_identifier():
394410 ),
395411 column_output ,
396412 ), "The selected column method is not correct"
413+ assert pd .DataFrame .equals (
414+ eda_utils_py .outlier_identifier (numeric_only_df , method = "trim" ), numeric_only_out
415+ ), "The numeric only method is not correct"
0 commit comments