0

I'm using movielens database and I need to create a dataframe about movies X genres in python. In other words, I need to transform the dataframe in a new binary dataframe.

This is the original dataframe

This is the dataframe I need to be created

How can I do this in a optimized way?

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
Mariana
  • 165
  • 1
  • 1
  • 8
  • 4
    Don't post DataFrames as images, post them as text – user3483203 Sep 16 '18 at 20:58
  • `df.set_index('movieID').genres.str.get_dummies(sep='|').reset_index()` – ALollz Sep 16 '18 at 21:27
  • Thank you ALollz! It was exactly what I needed! – Mariana Sep 17 '18 at 22:00
  • @Mariana Welcome to Stack Overflow! Your comment flag has been declined. Please read about [how to flag comments](https://meta.stackoverflow.com/questions/373801/when-is-a-comment-hostile-or-unfriendly-educating-newer-users-how-to-flag-comm). –  Sep 18 '18 at 02:07

0 Answers0