May-12-2020, 04:13 AM
Hello everyone,
I'm having some issue with this sample code using histogram & matplotlib, i can't display a bar for the first value Satisfaisant:
Best regards
I'm having some issue with this sample code using histogram & matplotlib, i can't display a bar for the first value Satisfaisant:
import json import datetime import requests import csv import pandas as pd import numpy as np import matplotlib.pyplot as plt r = requests.get('https://dgal.opendatasoft.com/api/records/1.0/search/?dataset=export_alimconfiance&q=rouen&facet=libelle_commune&facet=date_inspection&facet=app_libelle_activite_etablissement&facet=synthese_eval_sanit&facet=filtre&facet=ods_type_activite') data=r.json() sites = data["records"] with open('city.csv', 'w', newline='') as file: writer = csv.writer(file) writer.writerow(["Name", "Synthesis"]) for elt in sites: writer.writerow([elt["fields"]["app_libelle_etablissement"], elt["fields"]["synthese_eval_sanit"]]) print(elt["fields"]["app_libelle_etablissement"]) print(" |" + elt["fields"]["app_libelle_activite_etablissement"]) print(" |" + elt["fields"]["ods_type_activite"]) print(" |" + elt["fields"]["ods_adresse"]) print(" |" + elt["fields"]["synthese_eval_sanit"]) print() table = pd.read_csv("city.csv") file = open("city.csv") reader = csv.reader(file) lines= len(list(reader)) plt.bar(x=np.arange(1,lines),height=table['Synthesis']) table.head() plt.title("Restaurants Synthesis") plt.xticks(np.arange(1,lines), table['Name'], rotation='33', fontsize=5) plt.yticks(rotation='50', fontsize=8) plt.xlabel("Restaurants") plt.ylabel("Synthesis") plt.show()Can you help me? Thank you,
Best regards