# Query for seeing dates on which integers in another column change

**URL:** <https://discourse.julialang.org/t/query-for-seeing-dates-on-which-integers-in-another-column-change/70286>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [October 24, 2021, 10:49am UTC](https://discourse.julialang.org/t/query-for-seeing-dates-on-which-integers-in-another-column-change/70286 "2021-10-24T10:49:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)\
**Post date:** [October 24, 2021, 10:49am UTC](https://discourse.julialang.org/t/query-for-seeing-dates-on-which-integers-in-another-column-change/70286/1 "2021-10-24T10:49:58Z")

</div>

Suppose I have a Dataframe. One of the columns contains Dates sorted from low to high. Another columns contains integers. On particular dates, the value in the integer-column changes. What query will allow me to find see the dates on which the value in the integer-column has changed?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 24, 2021, 11:09am UTC](https://discourse.julialang.org/t/query-for-seeing-dates-on-which-integers-in-another-column-change/70286/2 "2021-10-24T11:09:27Z")

</div>

I want to say just use a for-loop but you can also do this I suppose

```julia
julia> df = DataFrame(dates=today()-Day(5):Day(1):today(), ints = [1,1,2,3,3,4])
6×2 DataFrame
 Row │ dates ints  
     │ Date Int64 
─────┼───────────────────
   1 │ 2021-10-19 1
   2 │ 2021-10-20 1
   3 │ 2021-10-21 2
   4 │ 2021-10-22 3
   5 │ 2021-10-23 3
   6 │ 2021-10-24 4

julia> df[[0;diff(df.ints)] .!= 0, :]
3×2 DataFrame
 Row │ dates ints  
     │ Date Int64 
─────┼───────────────────
   1 │ 2021-10-21 2
   2 │ 2021-10-22 3
   3 │ 2021-10-24 4

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 24, 2021, 8:14pm UTC](https://discourse.julialang.org/t/query-for-seeing-dates-on-which-integers-in-another-column-change/70286/3 "2021-10-24T20:14:29Z")

</div>

If one also wants to keep the first date as a reference, an alternative:

```julia
df.dates[df.ints .!= circshift(df.ints,1)]

4-element Vector{Date}:
 2021-10-19
 2021-10-21
 2021-10-22
 2021-10-24

```
