I have the following list:
import json
import pprint
scoring_dictionary=[{'IMEI': '867',
'Timestamp': '2020-07-02 13-29-24',
'RAG': 'G',
'Probability': 0.12},
{'IMEI': '430',
'Timestamp': '2020-07-02 13-29-24',
'RAG': 'G',
'Probability': 0.12},
{'IMEI': '658',
'Timestamp': '2020-07-02 13-29-24',
'RAG': 'G',
'Probability': 0.12},
{'IMEI': '157',
'Timestamp': '2020-07-02 13-29-24',
'RAG': 'G',
'Probability': 0.12},
{'IMEI': '521',
'Timestamp': '2020-07-02 13-29-24',
'RAG': 'G',
'Probability': 0.12}]
And I want to pretty print this in the standard output of a cell. Having seen this code on an online similar question,
print("The list of dictionaries per scored asset id: {0}".format(json.dumps(json.loads(scoring_dictionary), indent=4)))
But the output still remains bad
"The list of dictionaries per scored asset id: [{'IMEI': '867', 'Timestamp': '2020-07-02 13-29-24', 'RAG': 'G', 'Probability': 0.12}, {'IMEI': '430', 'Timestamp': '2020-07-02 13-29-24', 'RAG': 'G', 'Probability': 0.12}...]" # a straight text of string without intends
Apart from the list of dictionaries I want also to pretty print a dictionary which seems like:
{'failed_devices': ['334', '897', '485'], 'partially_succeeded_devices': ['867', '430', '658', '157', '521'], 'total_failures': 705, 'total_partially_succeeded': 268, 'total_succeeded': 26, 'total': 999, 'timestamp': '2020-07-02 13-29-24', 'failures_threshold': 0.1, 'failed_percentage_out_of_total': 0.7057057057057057}
I want to pretty print it in the same exact way like the above list of dictionaries.
[UPDATE] This worked better than pprint. Thanks to all answers. Appreciate your concern.
print("The list of sotred metrics depicting the complete batch scoring execution: {0}".format(json.dumps(scoring_dictionary, indent=2)))
Thank you in advance for any help.