1

I have dataframe look like:

  item_id   item_name   item_desc  rating item_type     price
0     it1      laptop                 6.0      asus   50000.0
1     it1      laptop                 7.0      acer   30000.0
2     it1      laptop                 3.0        hp   20000.0
3     it2  smartphone                 6.0    iphone  600000.0
4     it2  smartphone                 5.0   samsung  750000.0
5     it1      laptop                 4.0      dell   10000.0
6     it3       radio  Best radio     8.0      tech   30000.0
7     it3       radio  Best radio     9.0      tech   30000.0

And I wanna change them look like:

  item_id   item_name   item_desc  average_rating               item_type  \
0     it1      laptop                         4.0  [asus, acer, hp, dell]   
1     it2  smartphone                         5.5       [iphone, samsung]   
2     it3       radio  Best radio             8.5                  [tech]   

                          price  
0  [50000, 30000, 20000, 10000]  
1              [600000, 750000]  
2                       [30000]  

From above, I wanna change multiple datas from column rating into average_rating, convert multiple datas from item_type & price into list.

Could you help me how about the script program in python pandas?

arizals
  • 47
  • 2

0 Answers0