Hi there i am trying to create the strategy in course trading with machine learning.But the problem is i am not able to split the data and the time.I tried the following:
Df['date'] = pd.to_datetime(Df['date'])
Df['Time'],Df['date']= Df['date'].apply(lambda x:x.time()), Df['date'].apply(lambda x:x.date())
Df['Time'] gets created but the values come as 00:00:00 but i want it in 9:15:59 format.
Please help me out.
Hi thankfully i my issue was solved but i am not getting the results i wanted.Here is the error:
In line no 15
# Assign a value of 0 to 'Signal' column at 1529 time df.loc[(df.index.hour == 15) & (df.index.minute == 29), 'Signal'] = 0 # Assign a value of 0 to 'Ret' column at 1529 time df.loc[(df.index.hour == 15) & (df.index.minute == 29), 'Ret'] = 0 AttributeError: 'Index' object has no attribute 'hour'
Please guide me about the above and how to solve it.
You need first to set your Time column as an index.
Use this syntax:
DataFrame.set_index('column_name',inplace=True)
Once your column is set as an index, you can do your operations on the index of the dataframe.
Great thanks