Created
August 8, 2018 21:14
-
-
Save socratesk/d7975a159b2038a5d9e70fe343bdc829 to your computer and use it in GitHub Desktop.
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
import pandas as pd | |
gadgetDF = pd.DataFrame({'gadgetId' : [101, 102, 103, 104, 105], | |
'gadgetName' : ['Apple_iPhone_6', | |
'Apple_iPad_3', | |
'Samsung_Galaxy_S8', | |
'Samsung_Galaxy_S9', | |
'Google_Pixel_3']}) | |
dummyDF = gadgetDF['gadgetName'].apply(lambda x: pd.Series(x.split('_'))) | |
dummyDF.columns = ['company', 'gadget', 'version'] | |
gadgetDF = pd.concat([gadgetDF, dummyDF], axis=1) | |
gadgetDF = gadgetDF.drop(['gadgetName'], axis=1) | |
print(gadgetDF) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment