Skip to content

Tag: dataframe

How to create a list from dataframe pandas

My dataset contains columns of usersID and itemsID that they have purchased. Each user might have purchased more than 1 item. I neeed to make a list so that the key will be the userID and the values the itemsID he purchased for example if user_1 has purchased [item_20,item_25,item_32], my dataset contains 3 r…

ffill col[c] based on col[a]==Value

I have a dataframe [pixel, total_time], i want to: Make a new column “total_time_one”, which takes total_time of pixel 1 and projects it I have acheved the above dataframe with : Howver the code is quite long and repeats itself, is there a function better suited? or a better solution? Also i do no…

filter dates using pandas from dataframe

I have a column of dates. I need to filter out those dates that fall between today’s date and end of the current month. If the dates fall between these dates then the next column showns “Y” Date Column 01/02/2021 03/02/2021 31/03/2021 Y 01/03/2021 07/03/2021 Y 08/03/2021 Y Since today’…

Restructure Pandas DataFrame

I have the following DataFrame: play_id position frame x y 1 A_1 1 0.1 0.1 1 A_2 1 0.1 0.1 1 B_1 1 0.1 0.1 1 A_1 2 0.1 0.1 1 A_2 2 0.1 0.1 1 B_1 2 0.1 0.1 2 A_1 1 0.1 0.1 2 B_1 1 0.1 0.1 2 B_2 1 0.1 0.1 2 A_1 2 0.1 0.1