Last active
June 6, 2019 17:36
-
-
Save ravishchawla/09814c4f787e5d60ad8e14ad64f8b16a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'''Cleaning the *Portfolio* dataset''' | |
# Dummy-fy channel attributes | |
portfolio_channels = portfolio['channels'].apply(lambda x: ' '.join(x)).str.get_dummies(' '); | |
portfolio_channels.columns = ['channel_' + col for col in portfolio_channels.columns]; | |
# Dummy-fy offer type attributes | |
portfolio_offertype = portfolio['offer_type'].str.get_dummies() | |
portfolio_offertype.columns = ['offer_' + col for col in portfolio_offertype.columns]; | |
# Add dummy columns and drop existing | |
portfolio = pd.concat([portfolio, portfolio_channels, portfolio_offertype], axis=1); | |
portfolio = portfolio.drop(['channels', 'offer_type'], axis=1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment