Created
April 14, 2019 14:30
-
-
Save AVJdataminer/24e44f50292123cdd0faae82f27a5a68 to your computer and use it in GitHub Desktop.
get dummies columns for object type columns only and concat to dataframe
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
dfo=df.select_dtypes(include=['object']) # select object type columns | |
df = pd.concat([df.drop(dfo, axis=1), pd.get_dummies(dfo)], axis=1) |
Yes, the first line does. If there is only one column then in the second line there would be noting to concatenate to.
Aiden Johnson | Breakthrough Data Science ( http://www.breakthroughdatascience.com )
…On Fri, Jul 17, 2020 at 3:22 PM, ibrahimsevki < ***@***.*** > wrote:
***@***.**** commented on this gist.
Is this also applicable to one column?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (
https://gist.github.com/24e44f50292123cdd0faae82f27a5a68#gistcomment-3381828
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AHIYA6I2PTMRS67WX2N6VA3R4C6IHANCNFSM4O65CCAA
).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this also applicable to one column?