36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import pandas as pd
|
|
import json
|
|
from datetime import datetime
|
|
import numpy as np
|
|
import math
|
|
|
|
|
|
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)
|
|
none_df = pd.DataFrame(none_dict)
|
|
|
|
with open(root_dir+'output/none_dict.json', 'w', encoding='utf-8') as f:
|
|
json.dump(none_dict, f, ensure_ascii=False, indent=4)
|
|
|
|
# sensors_df = pd.DataFrame(sensors_dict)
|
|
|
|
# sensors_df.T.to_csv("sensors_df.csv")
|
|
# print(datetime.now().strftime("%s"))
|
|
none_df.T.to_csv(root_dir+"output/none_df.csv")
|
|
|
|
none_read_df = pd.read_csv(root_dir+"output/none_df.csv")
|
|
print(none_read_df)
|
|
# concat_df = pd.concat([none_read_df, none_read_df], ignore_index=True)
|
|
# print(concat_df.tail())
|