fix(dataabc): drop NaN values in key_to_dict/key_to_lists (#1211)

The dropna filter compared values against float("nan") using ==, which is
always False (NaN != NaN). As a result NaN values were never dropped when
dropna=True, letting them leak into key_to_series/key_to_array and downstream
resampling.

Use pd.isna() to detect NaN, matching the rest of the module. Add regression
tests that fail before and pass after the fix.

Co-authored-by: Cornelius Mund <cornim@users.noreply.github.com>
Co-authored-by: Normann <github@koldrack.com>
This commit is contained in:
Cornelius Mund
2026-08-01 13:13:24 +02:00
committed by GitHub
co-authored by Cornelius Mund Normann
parent b59012c1f7
commit 9189fc890e
2 changed files with 40 additions and 2 deletions
+2 -2
View File
@@ -1043,7 +1043,7 @@ class DataSequence(DataABC, DatabaseRecordProtocolMixin[DataRecord]):
if (
record.date_time is None
or (dropna and getattr(record, key, None) is None)
or (dropna and getattr(record, key, None) == float("nan"))
or (dropna and pd.isna(getattr(record, key, None)))
):
continue
record_date_time_timestamp = DatabaseTimestamp.from_datetime(record.date_time)
@@ -1122,7 +1122,7 @@ class DataSequence(DataABC, DatabaseRecordProtocolMixin[DataRecord]):
if (
record.date_time is None
or (getattr(record, key, None) is None) # key is not in record
or (dropna and getattr(record, key, None) == float("nan"))
or (dropna and pd.isna(getattr(record, key, None)))
):
continue
record_date_time_timestamp = DatabaseTimestamp.from_datetime(record.date_time)