weather-pydash/data-view.py

37 lines
1.0 KiB
Python
Raw Normal View History

import pandas as pd
2025-01-14 14:50:58 -07:00
import json
from datetime import datetime
2025-01-14 14:50:58 -07:00
import numpy as np
import math
2025-01-14 14:50:58 -07:00
def nan2None(obj):
if isinstance(obj, dict):
return {k:nan2None(v) for k,v in obj.items()}
elif isinstance(obj, list):
return [nan2None(v) for v in obj]
elif isinstance(obj, float) and math.isnan(obj):
return None
return obj
root_dir = "/home/tonydero/projects/weather-pydash/"
sensors_dict = pd.read_pickle(root_dir+"output/saved_sensors_dict.pkl")
none_dict = nan2None(sensors_dict)
2025-01-14 15:04:03 -07:00
print(none_dict.keys())
# none_df = pd.DataFrame(none_dict)
2025-01-14 14:50:58 -07:00
2025-01-14 15:04:03 -07:00
# with open(root_dir+'output/none_dict.json', 'w', encoding='utf-8') as f:
# json.dump(none_dict, f, ensure_ascii=False, indent=4)
2025-01-14 14:50:58 -07:00
# sensors_df = pd.DataFrame(sensors_dict)
# sensors_df.T.to_csv("sensors_df.csv")
# print(datetime.now().strftime("%s"))
2025-01-14 15:04:03 -07:00
# none_df.T.to_csv(root_dir+"output/none_df.csv")
2025-01-14 14:50:58 -07:00
2025-01-14 15:04:03 -07:00
# none_read_df = pd.read_csv(root_dir+"output/none_df.csv")
# print(none_read_df)
2025-01-14 14:50:58 -07:00
# concat_df = pd.concat([none_read_df, none_read_df], ignore_index=True)
# print(concat_df.tail())