From 7ba68802cfc48c312fd4fef198e729090d9c3767 Mon Sep 17 00:00:00 2001 From: corruptbear Date: Thu, 7 Mar 2024 17:26:43 -0800 Subject: [PATCH] Suppress pandas scientific notification to facilitate data examination --- software/management/dashboard/processing.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/software/management/dashboard/processing.py b/software/management/dashboard/processing.py index 6eeadb8e..9dc706d0 100755 --- a/software/management/dashboard/processing.py +++ b/software/management/dashboard/processing.py @@ -6,13 +6,16 @@ from datetime import datetime, timedelta import matplotlib.pyplot as plt import matplotlib.dates as mdates -import pandas, pickle +import pandas as pd +import pickle import numpy as np from matplotlib.widgets import Slider from matplotlib.widgets import TextBox import textwrap import re +# suppress the pandas scientific notation +pd.options.display.float_format = '{:.3f}'.format # HELPER FUNCTIONS ---------------------------------------------------------------------------------------------------- def seconds_to_human_readable(seconds): @@ -55,8 +58,9 @@ def extract_simple_event_log(logpath): def load_data(filename): with open(filename, 'rb') as file: - data = pandas.json_normalize(data=pickle.load(file)) - return data.set_index('t').reindex(pandas.Series(np.arange(data.head(1)['t'].iloc[0], 1+data.tail(1)['t'].iloc[0]))).T \ + data = pd.json_normalize(data=pickle.load(file)) + print(data) + return data.set_index('t').reindex(pd.Series(np.arange(data.head(1)['t'].iloc[0], 1+data.tail(1)['t'].iloc[0]))).T \ if data is not None and len(data.index) > 0 else None def plot_data(title, x_axis_label, y_axis_label, x_axis_data, y_axis_data): @@ -90,7 +94,7 @@ def extract_ranging_time_series(data, destination_tottag_label, start_timestamp= conversion_factor_from_mm = 1000.0 ranges = data.loc['r.' + destination_tottag_label] / conversion_factor_from_mm ranges = ranges.mask(ranges > cutoff_distance)\ - .reindex(pandas.Series(np.arange(start_timestamp if start_timestamp is not None else data.T.head(1).index[0], + .reindex(pd.Series(np.arange(start_timestamp if start_timestamp is not None else data.T.head(1).index[0], end_timestamp if end_timestamp is not None else 1+data.T.tail(1).index[0]))) timestamps = mdates.date2num([datetime.fromtimestamp(ts) for ts in ranges.keys()]) return timestamps, ranges