I've been working on sklearn with the Kaggle Titanic set, and just discovered sklearn Pipelines and FeatureUnions. While following most of the content out there on how to work with the Titanic dataset, I started to rewrite all the usual functions into Transformers, that can be used in the FeatureUnion/Pipeline context.
Usually, you use FeatureUnions for (axis=1) concatenation of transformers output. Here, I created a UnityTransformer that effectively does nothing to the input, that way I could keep the original column, and concatenate it with a transformed version of itself.
The 'trick' here is in the transform method: just multiply the output by 1, a unity operation. I haven't extensively tested it, but it seems to work fine for strings as well as normal np.arrays. The whole thing feels a little hacky though, so I'll be happy to have feedback.
from sklearn.base import BaseEstimator, TransformerMixin
class IdentityTransformer(BaseEstimator, TransformerMixin):