I Have one pandas series with multiple index like this image "target","Lastnewjob", "experienceGroup". this is pandas.core.series.series type. I want to convert it to a dataframe(second image) where "experienceGroup" values will be column names and "target","Lastnewjob" remains as columns.
Dataframe that I want to see
Code to get the series by using groupby.
Job=df.groupby(['target','last_new_job'])['experienceGroup'].value_counts()
Job.unstack()
-- Pandas series
Adding more details So that you can create the Job- pandas series actually resulted from groupBy and value_counts()
details={
"experienceGroup":['0-5','6-12','13-19','20 & above','0-5','6-12','13-19','20 & above'],
"last_new_job":[1,'>4',2,"never",4,3,3,4],
"target":[1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0],
"experience":[1,7,15,20,3,8,17,25] }
df5 = pd.DataFrame(details)
df5
To create Pandas series and display it by unstacking- use the below code
Job=df5.groupby(['target','last_new_job'])['experienceGroup'].value_counts()
Job.unstack()