# Define a stock we want to look at along with some dates
stock = 'AAPL'
start_date = '1-1-2020'
end_date = '1-20-2020'
# get minute data
minute_data = get_pricing(stock, start_date, end_date, frequency='minute')
minute_data.head(5)
# get daily data
daily_data = get_pricing(stock, start_date, end_date, frequency='daily')
daily_data.head(5)
# Let's calculate daily data from the minute data using 'groupby'
# First add a column for day to group on
minute_data['day'] = minute_data.index.get_level_values(level=0).date
minute_data.head(5)
# Now group and apply appropriate functions
calculated_daily_data = minute_data.groupby('day').aggregate({'open_price':'first',
'high':'max',
'low':'min',
'close_price':'last',
'volume':'sum',
'price':'last'})
display(calculated_daily_data.head(5))
display(daily_data.head(5))
Notice that the aggregated minute data is the same as the daily data.