def ohlcsum(df):
    df = df.sort()
return {'Open': df['Open'][0], 'High': df['High'].max(), 'Low': df['Low'].
    min(), 'Close': df['Close'][-1], 'Volume': df['Volume'].sum()}
Converting OHLC stock data into a different timeframe with python and pandas