Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

getting dummies and input them to pandas dataframe

note:
dummies = pd.get_dummies(df[['column_1']], drop_first=True)
df = pd.concat([df.drop(['column_1'],axis=1), dummies],axis=1)


note:for more that one coloum keep ading in the list 
dummies = pd.get_dummies(df[['column_1', 'column_2','column_3']], drop_first=True)
df = pd.concat([df.drop(['column_1', 'column_1'],axis=1), dummies],axis=1)
Comment

PREVIOUS NEXT
Code Example
Python :: python print to file 
Python :: python calculate computation time 
Python :: how to send whatsapp message with python 
Python :: matplotlib plot two graphs side by side 
Python :: mean squared error python 
Python :: check python version ubuntu 
Python :: how to calculate running time in python 
Python :: pandas determine percentage of nans in column 
Python :: grid in pygame 
Python :: char to binary python 
Python :: python diamond print 
Python :: python pil invert image color 
Python :: set icon title tkinter 
Python :: pandas read csv with index 
Python :: qtimer python 
Python :: python copy dir 
Python :: df from numpy array 
Python :: what happen when we apply * before list in python 
Python :: bgr to gray opencv 
Python :: how to clear console in repl.it python 
Python :: plt line of best fit 
Python :: r2 score sklearn 
Python :: dataframe to list 
Python :: how to read pdf in python 
Python :: how to generate requirements.txt django 
Python :: round to two decimal places python 
Python :: brownie to wei 
Python :: pca in sklearn 
Python :: django import model from another app 
Python :: wtf forms required 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =