mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-08-31 12:46:38 +00:00
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:
co-authored by
Cornelius Mund
Normann
parent
b59012c1f7
commit
9189fc890e
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user