Instantly share code, notes, and snippets.

Embed
What would you like to do?
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