Hi All, I need to extract rows of dates from a dataframe based on list of values(e.g. dates) located in a CSV file. Can anyone please help me? I have tried groupby function but am not able to get the expected result. Thanks in advance.

SindhuG
New Contributor

my dataframe looks like this.

df =

Datecolumn2column3Machine1-jan-2020A2-jan-2020

-

-

-

A

18-jan-2020

A

11-jan-2020

B

12-jan-2020

B

6-feb-2020C7-feb-2020

-

-

-C14-feb-2020C

Date details csv file looks like this

D =

MachineSelected DateA15-jan-2020C12-feb-2020

I need to pick date and machine from the csv file "D" and in dataframe "df" for that machine, i need to extract the last 3 rows from the 'selected date'.

So Outcome should be

Datecolumn2column3Machine13-jan-2020A14-jan-2020

A15-jan-2020A10-feb-2020C11-feb-2020

C12-feb-2020C