Skip to content
Snippets Groups Projects
Unverified Commit e2a7fc70 authored by David Hoese's avatar David Hoese
Browse files

Fix NaNs in JSON

parent 1b57f220
No related branches found
No related tags found
No related merge requests found
......@@ -160,6 +160,8 @@ def handle_csv(frame, epoch, sep=',',
@as_json_p(optional=True)
def handle_json(frame, epoch, order='columns',
message='', code=200, status='success', **kwargs):
# replace NaNs with None
frame = frame.where(pd.notnull(frame), None)
output = {}
output['status'] = status
output['message'] = message
......
......@@ -20,6 +20,11 @@ def fake_data(interval, symbols, num_vals):
[(now + timedelta(minutes=i)).strftime(t_format)] + \
[random.random()] * (len(columns) - 1)
)
# make up some Nones/nulls (but not all the time)
r_idx = int(random.random() * len(columns) * 3)
# don't include time (index 0)
if 0 < r_idx < len(columns):
vals[-1][r_idx] = None
s = {
'name': measurement_name,
'columns': columns,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment