Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify the last occurrence in a column of date format?

Tags:

julia

I have a dataset containing information of some purchases starting on 03/01/2018 03:00 and ending on 25/04/2022 15:00. There's no pattern between dates and times of purchase occurrences. For instance, there's no purchase happening on 04/01/2018 05:00 or 04/01/2018 15:00, etc. For each day, I am trying to find the latest time in which a purchase has happened.

For example, based on the following dataset, is it possible to have a dictionary that as a key stores dates and as a value the latest price of the purchase?

"03/01/2018" => 9.3
"04/01/2018" => 5.4
"03/01/2019" => 7.6
.... all the way to 25/04/2022 15:00

enter image description here

like image 391
Hemfri Avatar asked Oct 31 '25 06:10

Hemfri


1 Answers

Using InMemoryDatasets package:

ds=Dataset(df)
setformat!(ds,:date=>yearmonthday) # no data modification - lazy format
unique(ds,:date,keep=:last,mapformats=true)
like image 101
giantmoa Avatar answered Nov 04 '25 02:11

giantmoa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!