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

I have a dataframe that contains stock symbols, stock prices, dates, and also financial quarters (obtained from the date column using the package PeriodicalDates).

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?

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

4 Likes

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

2 Likes