Skip to content
Advertisement

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 rows for this user as follows row_1=

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 not undestand why if i put: It

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’s date is 07/03/2021 three dates fall between 07/03/2021 and 31/03/2021.

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

Pandas fillna based on a condition

I’m still new to pandas, but I have a dataframe in the following format: and I’m trying to fill all NaN fields in the ‘d_header’ column using the following conditions: ‘d_header’ column should be set only for rows belonging to the same group the group should be determined by the ‘d_prefix’ column value of a row immediately after non-Nan ‘d_header’

Advertisement