Skip to content

Tag: pandas

Find all ids that have 2 specific values for a one column

I have a dataframe that contains data of employees, their managers and the projects they worked on. The dataframe (a bit simplified) looks like this: I would like get all employees that have both worked with manager 17 and 18, in this case that would be employee 2 and employee 6. I know I can write a query to…

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’…

Pandas dataframe diff between rows with column offset

I have a Dataframe with the following structure time_start time_end label time time + 1 action time + 1 time + 2 some_other_action I would like to take see the diff of time_start and previous row time_end. in this case (time + 1) – (time + 1) = 0 I have tried df.diff, but that only yields the diff withi…

How to convert object to float in Pandas?

I read a csv file into a pandas dataframe and got all column types as objects. I need to convert the second and third columns to float. I tried using but got NaN. Here’s my dataframe. Should I need to use some regex in the third column to get rid of the “R$ “? Answer Try this: Output: