0

i'm new to python and i have been trying to manipulate the following data which is in csv (this is just a sample, the file is around 15,000 rows)

chat_ID   attribute 

185492    taxi_booking
185492    confirm_time 
124503    restaurant_cancel
124503    confirm_cancel  
153021    taxi_booking
153021    confirm_time
153021    taxi_cancel
153021    confirm_cancel 
199821    greetings
184392    greetings
184392    bus_timing 
184392    bus_reserve
184392    confirm_reserve 
184392    transfer

I want to transform the "attribute" column into several rows. this is how I want the data to look like:

chat_ID   attribute1          attribute2          attribute3        attribute4        attribute5

185492    taxi_booking        confirm_time 
124503    restaurant_cancel   confirm_cancel   
153021    taxi_booking        confirm_time        taxi_cancel       confirm_cancel  
199821    greetings
184392    greetings           bus_timing          bus_reserve       confirm_reserve  transfer

I tried converting the file to excel and using OFFSET and INDEX functions but I wasn't able to transform it because the data is too large

Does anyone have any idea what I can do? Does panda transpose function help?

Anwarvic
  • 12,156
  • 4
  • 49
  • 69

0 Answers0