I have a Pandas DataFrame with two columns – one with the filename and one with the hour in which it was generated:
DataFrame
File Hour F1
convert data-frame to list of dictionary
list_dict = [] for index, row in list(df.iterrows()): list_dict.append(dict(row))
save file
with open("output.json", mode) as f: f.write("\n".join(str(item) for item in list_dict))