From 576e6f677cf6623f9cd271da5b724b4ac2d8b5a6 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Mon, 3 Feb 2025 17:39:06 +0000 Subject: [PATCH] lisa.datautils: Speedup df_refit_index() FEATURE Speed up df_refit_index() by using col != col.shift(1) rather than the much slower col.diff() != 0. --- lisa/datautils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisa/datautils.py b/lisa/datautils.py index ee9180de9..9dd6d163a 100644 --- a/lisa/datautils.py +++ b/lisa/datautils.py @@ -609,7 +609,7 @@ def _polars_refit_index(data, window): # "end" had a lower value than the unclipped index, we get rid of all # the excess rows. data = data.filter( - (index_col != end) | (index_col.diff() != 0) + (index_col != end) | (index_col != index_col.shift(1)) ) return data -- GitLab