I want to create a scatter plot for every 10 minutes in the time period specified by t_list. I get the error TypeError: cannot compare a dtyped [datetime64[ns]] array with a scalar of type [bool] in the line df_t = df[(df['datetime']>=t & df['datetime']<t_end)] but the type for t and t_endare both datetime. non of the variables are type bool.
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
df_data = pd.read_csv('C:\SCADA.csv')#import data
#format Timestamp as datetime
df_data['datetime'] = pd.to_datetime(df_data['TimeStamp'] )
#create df of time period
df = df_data[(df_data['datetime']>= datetime(2017, 12, 23, 06,00, 00)) &
(df_data['datetime']< datetime(2017, 12, 23, 07, 00, 00))]
#time period I want to create 10 min plots for
t_list = [datetime(2017, 12, 23, 06, 00, 00), datetime(2017, 12, 23, 07, 00, 00)]
for t in t_list:
t_end = t + timedelta(minutes = 10)
#breaks here with
TypeError: cannot compare a dtyped [datetime64[ns]] array with a
scalar of type [bool]
df_t = df[(df['datetime']>=t & df['datetime']<t_end)]
#code continues with plotting scatter plots within the loop
type(df['datetime'].iloc[0]),type(t)andtype(t_end)?pandas.tslib.Timestamp,datetime.datetimeanddatetime.datetimerespectively