cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

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

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @ SindhuG! My name is Kaniz, and I'm a technical moderator here. Great to meet you, and thanks for your question! Let's see if your peers on the Forum have an answer to your questions first. Or else I will follow up shortly with a response.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.