Skip to content

Instantly share code, notes, and snippets.

@StevenReitsma
Created February 23, 2018 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StevenReitsma/b6e067ef1784ffae4d97f395f5f9d889 to your computer and use it in GitHub Desktop.
Save StevenReitsma/b6e067ef1784ffae4d97f395f5f9d889 to your computer and use it in GitHub Desktop.
Blogpost-Pandas3
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