The following code creates a column in the DataFrame with the hour from the index as an integer
import pandas as pd
data = pd.read_csv('data/BTCUSDT-4h.csv', index_col = 0,
parse_dates=True)
data['hour'] = [x.hour for x in data.index]