From d73d627759275e782a762a066c795c53e39b92dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Mon, 15 Jul 2024 02:11:55 +0000 Subject: [PATCH] Dels with empty results in query_influxdb --- src/lvmapi/tools/influxdb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lvmapi/tools/influxdb.py b/src/lvmapi/tools/influxdb.py index 018c944..dbbe7cc 100644 --- a/src/lvmapi/tools/influxdb.py +++ b/src/lvmapi/tools/influxdb.py @@ -48,6 +48,8 @@ async def query_influxdb(query: str) -> polars.DataFrame: query_results = await api.query(query) df = polars.DataFrame(json.loads(query_results.to_json())) - df = df.with_columns(polars.col._time.cast(polars.Datetime("ms"))) + + if len(df) > 0: + df = df.with_columns(polars.col._time.cast(polars.Datetime("ms"))) return df