Creating dummy variables in python

python

#1

Hi,

Currently I am working on megastar contest on AV. Below is the structure of data set :

I want to create new variables for each skill as shown below for two cadidates :
1->['sas','python','r'] 2->['r','tableau']
output :

I have changed the “Skills” variable in from of a list for each candidate as shown above(for the two candidates), furthermore I have tried pd.get_dummies but it is taking each element as different levels.

Please suggest the fastest way to do so in Python.

Thanks


#2

Hi @syed.danish

Is there any way to join 2 dataframes in python on different columns. I am trying to think on these lines

a0=[0,0,0,0]
a1=[1,1,1,1]
b0=[0,0,0,0]
b1=[1,1,1,1]

If i want to join a1 and b0, then i can use the comand
a1.join(b0,on= )

I am having trouble here. Can i mention two different column names on the two different data frames?


#3

@anantguptadbl,
You can perform join operation by renaming the columns in both a1 and b0 on which you have to join or you can make the desired columns as the index and by default join will merge on the basis of index.
I cannot see how this approach will help in creating dummy varibles, Can you please explain that too?
Regards,
Danish