Repository: feature-engine/feature_engine
Pull request #595 (2023-01-16 14:37:38)

add contributors badge to about

codecov[bot]: # [Codecov](https://codecov.io/gh/feature-engine/feature_engine/pull/595?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) Report
> Merging [#595](https://codecov.io/gh/feature-engine/feature_engine/pull/595?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) (aaff6af) into [main](https://codecov.io/gh/feature-engine/feature_engine/commit/a0106c968b14922d5123aaf51625fa66123dfad8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine) (a0106c9) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##             main     #595   +/-   ##
=======================================
  Coverage   97.79%   97.79%           
=======================================
  Files          90       90           
  Lines        3496     3496           
  Branches      684      684           
=======================================
  Hits         3419     3419           
  Misses         29       29           
  Partials       48       48           
```



:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=feature-engine)


Patch:
diff --git a/docs/about/about.rst b/docs/about/about.rst
index 3083494..1c59d94 100644
--- a/docs/about/about.rst
+++ b/docs/about/about.rst
@@ -44,6 +44,11 @@ and maintenance:
 Contributors
 ------------
 
+.. image:: https://img.shields.io/github/contributors/feature-engine/feature_engine?logo=GitHub
+   :target: https://github.com/feature-engine/feature_engine/graphs/contributors
+
+|
+
 A growing international community is beginning to lead Feature-engine's development.
 You can learn more about Feature-engine's Contributors in the
 `GitHub contributors page <https://github.com/feature-engine/feature_engine/graphs/contributors>`_.
diff --git a/feature_engine/selection/drop_features.py b/feature_engine/selection/drop_features.py
index b4ecd80..708bedd 100644
--- a/feature_engine/selection/drop_features.py
+++ b/feature_engine/selection/drop_features.py
@@ -2,6 +2,9 @@ from typing import List, Union
 
 import pandas as pd
 
+from feature_engine._variable_handling.variable_type_selection import (
+    _find_all_variables,
+)
 from feature_engine.dataframe_checks import check_X
 from feature_engine.selection.base_selector import BaseSelector
 from feature_engine.tags import _return_tags
@@ -54,7 +57,6 @@ class DropFeatures(BaseSelector):
     """
 
     def __init__(self, features_to_drop: List[Union[str, int]]):
-
         if not isinstance(features_to_drop, (str, list)) or len(features_to_drop) == 0:
             raise ValueError(
                 f"features_to_drop should be a list with the name of the variables "
@@ -81,10 +83,10 @@ class DropFeatures(BaseSelector):
         # present in the df.
         X[self.features_to_drop]
 
-        self.features_to_drop_ = self.features_to_drop
+        self.features_to_drop_ = _find_all_variables(X, variables=self.features_to_drop)
 
         # check user is not removing all columns in the dataframe
-        if len(self.features_to_drop) == len(X.columns):
+        if len(self.features_to_drop_) == len(X.columns):
             raise ValueError(
                 "The resulting dataframe will have no columns after dropping all "
                 "existing variables"


Test patch:
diff --git a/tests/test_selection/test_drop_features.py b/tests/test_selection/test_drop_features.py
index 49cb8db..70acfd9 100644
--- a/tests/test_selection/test_drop_features.py
+++ b/tests/test_selection/test_drop_features.py
@@ -27,6 +27,32 @@ def test_drop_1_variable(df_vartypes):
     pd.testing.assert_frame_equal(X, df)
 
 
+def test_drop_1_variables_str_input(df_vartypes):
+    """check that the internal variable features_to_drop has been
+     correctly cast from :str: to list of :str: internally"""
+
+    transformer = DropFeatures(features_to_drop="Marks")
+    X = transformer.fit_transform(df_vartypes)
+
+    # expected result
+    df = pd.DataFrame(
+        {
+            "Name": ["tom", "nick", "krish", "jack"],
+            "City": ["London", "Manchester", "Liverpool", "Bristol"],
+            "Age": [20, 21, 19, 18],
+            "dob": pd.date_range("2020-02-24", periods=4, freq="T"),
+        }
+    )
+
+    # init params
+    assert transformer.features_to_drop == "Marks"
+
+    # transform params
+    assert X.shape == (4, 4)
+    assert type(X) == pd.DataFrame
+    pd.testing.assert_frame_equal(X, df)
+
+
 def test_drop_2_variables(df_vartypes):
     transformer = DropFeatures(features_to_drop=["City", "dob"])
     X = transformer.fit_transform(df_vartypes)