Я хочу создать точечный график для каждых 10 минут в период времени, заданный t_list
. Я получаю сообщение об ошибке TypeError: cannot compare a dtyped [datetime64[ns]] array with a scalar of type [bool]
в строке df_t = df[(df['datetime']>=t & df['datetime']<t_end)]
, но оба типа t
и t_end
имеют тип datetime
. не переменные имеют тип 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