0

I am working on eCommerce Events History in Cosmetics Shop dataset which you can find whole dataset here. I have to take one item from each user's basket and then predict that item.

Simply, I have dataset like this :

import pandas as pd
pd.read_clipboard(sep='\s\s+')
df3 = pd.DataFrame([[1,12,111], [1, 13,111], [1, 14,111]], columns=['user_id', 'product_id','session_id'])



   user_id  product_id  session_id
0        1          12         111
1        1          13         111
2        1          14         111

I want to transform that dataset to below form :

       user_id  product_id1  product_id2  product_id3  session_id  target_id
0        1          NaN         12.0           13         111         11
1        1         11.0          NaN           13         111         12

As you see target_id column is consist of removed item from each user's basket. After getting this dataset I want to do classification to predict this removed item

  • 1
    Can you specify more the question ? – Elmahy Apr 22 '20 at 22:44
  • Welcome to stack overflow! Please don't post sample data or code as pictures or links, as we can't reproduce that. Instead provide a [mcve] in the text of your question including sample input, sample output, and code for what you've tried so far. See [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – G. Anderson Apr 22 '20 at 23:14
  • @G.Anderson thank you for your help, I have edited my question, I hope it is clear for everyone now – Anar Sultani Apr 22 '20 at 23:49
  • Does this answer your question? [How to pivot a dataframe](https://stackoverflow.com/questions/47152691/how-to-pivot-a-dataframe) – G. Anderson Apr 23 '20 at 15:19

0 Answers0