Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 7630168

Browse files
author
Daniel Cogswell
committed
Workaround to ensure the Timestamp field is datetime64 rather than an
object. This addresses the PerformanceWarning in #86.
1 parent 485671c commit 7630168

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

NewareNDA/NewareNDAx.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def _read_ndc_11_filetype_18(mm):
398398
rec.append([Time/1000,
399399
Charge_Capacity/3600, Discharge_Capacity/3600,
400400
Charge_Energy/3600, Discharge_Energy/3600,
401-
datetime.fromtimestamp(Timestamp, timezone.utc).astimezone(), Step, Index])
401+
datetime.fromtimestamp(Timestamp, timezone.utc), Step, Index])
402402

403403
# Create DataFrame
404404
df = pd.DataFrame(rec, columns=[
@@ -408,6 +408,10 @@ def _read_ndc_11_filetype_18(mm):
408408
'Timestamp', 'Step', 'Index']).astype({'Time': 'float'})
409409
df['Step'] = _count_changes(df['Step'])
410410

411+
# Convert timestamp to local timezone
412+
tz = datetime.now().astimezone().tzinfo
413+
df['Timestamp'] = df['Timestamp'].dt.tz_convert(tz)
414+
411415
return df
412416

413417

@@ -473,7 +477,7 @@ def _read_ndc_14_filetype_18(mm):
473477
rec.append([Time/1000,
474478
Charge_Capacity*1000, Discharge_Capacity*1000,
475479
Charge_Energy*1000, Discharge_Energy*1000,
476-
datetime.fromtimestamp(Timestamp, timezone.utc).astimezone(), Step, Index])
480+
datetime.fromtimestamp(Timestamp, timezone.utc), Step, Index])
477481

478482
# Create DataFrame
479483
df = pd.DataFrame(rec, columns=[
@@ -483,6 +487,10 @@ def _read_ndc_14_filetype_18(mm):
483487
'Timestamp', 'Step', 'Index']).astype({'Time': 'float'})
484488
df['Step'] = _count_changes(df['Step'])
485489

490+
# Convert timestamp to local timezone
491+
tz = datetime.now().astimezone().tzinfo
492+
df['Timestamp'] = df['Timestamp'].dt.tz_convert(tz)
493+
486494
return df
487495

488496

0 commit comments

Comments
 (0)