# Dataframe that includes the first trading day of each financial quarter only

**URL:** <https://discourse.julialang.org/t/dataframe-that-includes-the-first-trading-day-of-each-financial-quarter-only/86654>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [September 1, 2022, 5:25pm UTC](https://discourse.julialang.org/t/dataframe-that-includes-the-first-trading-day-of-each-financial-quarter-only/86654 "2022-09-01T17:25:22Z")\
**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:** [September 1, 2022, 5:25pm UTC](https://discourse.julialang.org/t/dataframe-that-includes-the-first-trading-day-of-each-financial-quarter-only/86654/1 "2022-09-01T17:25:22Z")

</div>

I have a dataframe that contains stock symbols, stock prices, dates, and also financial quarters (obtained from the date column using the package [PeriodicalDates](https://docs.juliahub.com/PeriodicalDates/b908U/2.0.0/)).

I have sorted the dataframe by symbol and date, and here is now what I want to do. I want to create a new dataframe that only holds the first rows of a particular quarter for each symbol. How can I achieve that?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 1, 2022, 5:40pm UTC](https://discourse.julialang.org/t/dataframe-that-includes-the-first-trading-day-of-each-financial-quarter-only/86654/2 "2022-09-01T17:40:01Z")

</div>

`combine(groupby(df, [:ticker, :quarter]), names(df).=> first)`, assuming you have an appropriate quarter column.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 2, 2022, 6:06am UTC](https://discourse.julialang.org/t/dataframe-that-includes-the-first-trading-day-of-each-financial-quarter-only/86654/3 "2022-09-02T06:06:42Z")

</div>

`combine(groupby(df, [:ticker, :quarter]), first)` is enough, as `first` on data frame returns its first row.
