Created
February 23, 2018 12:19
-
-
Save StevenReitsma/b6e067ef1784ffae4d97f395f5f9d889 to your computer and use it in GitHub Desktop.
Blogpost-Pandas3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.base import BaseEstimator, TransformerMixin | |
class TypeSelector(BaseEstimator, TransformerMixin): | |
def __init__(self, dtype): | |
self.dtype = dtype | |
def fit(self, X, y=None): | |
return self | |
def transform(self, X): | |
assert isinstance(X, pd.DataFrame) | |
return X.select_dtypes(include=[self.dtype]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment