Last active
May 20, 2016 11:16
-
-
Save tbrittoborges/9bbb5ff9fb0465e080b435c76a707ae4 to your computer and use it in GitHub Desktop.
Pandas unlistfy one colum
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
df['new'] = df['new'].str.split('/') # example how to listfy a column of strings | |
temp = pd.DataFrame(df['new'].dropna().tolist()) | |
temp = temp.stack() | |
temp.index = temp.index.droplevel(1) # index need to be coherent with the original dataframe | |
temp.name = 'new_colum' # name of the new column in the original dataframe | |
df = df.join(temp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment