while i am trying to resample my dataframe in python using pandas. i am getting builtins.KerError: 'Date' when i am trying to split my index in the first dataframe.
I am very new to development and any answer with a reason why it was getting generated would be of lot of help.
this is how my dataframe looks like with multiple entries for each second, on which i wanted to do ohlc resampling.
Time Token LTP Volume
0 2019-01-18 15:29:59 779521 294.95 9074206
0 2019-01-18 15:29:59 779521 294.95 9074206
0 2019-01-18 15:29:59 779521 294.95 9074206
0 2019-01-18 15:40:02 779521 294.95 9074723
0 2019-01-18 15:40:02 779521 294.95 9074723
0 2019-01-18 15:40:03 779521 294.95 9074725
0 2019-01-18 15:40:03 779521 294.95 9074725
0 2019-01-18 15:40:03 779521 294.95 9074725
0 2019-01-18 15:40:05 779521 294.95 9074736
0 2019-01-18 15:40:05 779521 294.95 9074736
0 2019-01-18 15:40:05 779521 294.95 9074736
0 2019-01-18 15:40:11 779521 294.95 9074986
0 2019-01-18 15:40:11 779521 294.95 9074986
0 2019-01-18 15:40:11 779521 294.95 9074986
0 2019-01-18 15:40:13 779521 294.95 9075386
0 2019-01-18 15:40:13 779521 294.95 9075386
0 2019-01-18 15:40:25 779521 294.95 9075586
0 2019-01-18 15:40:25 779521 294.95 9075586
0 2019-01-18 15:40:25 779521 294.95 9075586
0 2019-01-18 15:40:25 779521 294.95 9075586
0 2019-01-18 15:40:32 779521 294.95 9075686
0 2019-01-18 15:40:32 779521 294.95 9075686
0 2019-01-18 15:40:32 779521 294.95 9075686
0 2019-01-18 15:40:40 779521 294.95 9075687
0 2019-01-18 15:40:40 779521 294.95 9075787
0 2019-01-18 15:40:40 779521 294.95 9075787
0 2019-01-18 15:40:40 779521 294.95 9075787
0 2019-01-18 15:40:40 779521 294.95 9075787
My Code
df_cols = ["Time", "Token", "LTP", "Volume"]
data_frame = pd.DataFrame(data=[],columns=df_cols)
timeframe = '1min'
def on_ticks(ws, ticks): #retrive continius ticks in JSON format
global data_frame, df_cols
data = dict()
for tick in ticks:
Time = tick['last_trade_time']
Token = tick['instrument_token']
LTP = tick['last_price']
Volume = tick['volume']
data = [Time, Token, LTP, Volume]
tick_df = pd.DataFrame([data], columns=df_cols)
data_frame = data_frame.append(tick_df)
data_frame['Time'] = pd.to_datetime(data_frame['DATE'] + ' ' + data_frame['TIME'])
data_frame.set_index('Time', inplace=True)
i am getting the following error builtins.KerError: 'Date'