I'm trying to get moving average by weekday, for that I'm using sql query. Dataframe is
and sqldf code:
ma_782 = sqldf("SELECT
t1.Id_indicator, t1.Hour,
(
select SUM(t2.Value) / COUNT(t2.Value)
FROM max_value_782 AS t2
WHERE
t1.Hour = t2.Hour and
weekdays.Date(t1.Date) = weekdays.Date(t2.Date)
and DATEDIFF(t1.Date, t2.Date) BETWEEN 1 AND 42
) AS 'MA_by_weekday'
FROM max_value_782 AS t1 ;")
This gives error
Error in rsqlite_send_query(conn@ptr, statement) : near "(": syntax error
while it works from simple select:
sqldf("select * from max_value_782")
