2

I have a Music dataset. Where two columns ('Music_id' and 'Tag_name' ) are there. Sample data:

Music_id       Tag_name
  1004         Base Guitar
  1004         Guitar
  2004         Base guitar
  1005         Keyboard
  1003         Keyboard
  1004         Keyboard

I want to reshape this dataframe where all tag_name should become the column name, so that every row should have unique Music_id.

I read about the concept of stratification and merging but not sure how to apply in this situation. Any help?

1 Answer 1

2

Question not clear. Maybe give us what you expect output to be

I guess you need this?

pd.crosstab(df.Music_id, df.Tag_name, dropna=False)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.