cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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_Fatma
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.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!