In Python, I am analyzing a dataset about health inspections inNew York to make the conclusion on whether burgers, pizza, orChinese food restaurants perform "best" in health inspections. Thecriteria that I have set for "best" is found in the columns in thedataset: SCORE, Critical Flag, and Grade. The lower the score, theless occurrences of "critical" in Critical Flag, and the mostoccurrences of "A" in Grade all contribute to the conclusion of"best" for my conclusion. For each column that I analyze (Score,Critical Flag, and Grade), I want to make a graph (bar/pie) todemonstrate the analysis of the data.
(Point 1) For instance, for Score, I would like to make a newdataframe for hamburgers so that I have the columns "CuisineDescription" and "Score", and then find the average of thatdataframe to compare with the averages of identical dataframes,only respective to pizza and Chinese food. I have already includedin my code a standard average (all types of cuisine scoresaveraged, which is found in standard_average below) to be graphedalongside the average scores for burgers, pizza, and Chinesefood.
(Point 2) However, for Grade A and Critical Flag occurrences, Iam not sure how to begin writing the code.
Please help me code graphing Point 1 and Point 2!
Here is my code below:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from google.colab import drive
drive.mount('/content/drive')
df = pd.read_csv('/content/drive/MyDrive/DOHMH_New_York_City_Restaurant_Inspection_Results.csv')
from pandas._libs.lib import to_object_array_tuples
df = df.loc[(df["CUISINE DESCRIPTION"] != "s")
& (df["CRITICAL FLAG"] != "s")
& (df["SCORE"] != "s")]
df["SCORE"] = pd.to_numeric(df["SCORE"])
df = df.reset_index()
#all variables equal to the same value
DBA = 0
for i in range(len(df)): #for e/a row in dataframe:
if ("burger" in df["DBN"]) or ("burger" indf["CUISINE DESCRIPTION"]):
DBA += df["DBA"]
elif ("pizza" in df["DBN"]) or ("pizza" indf["CUISINE DESCRIPTION"]):
DBA += df["DBA"]
elif ("chinese" in df["DBN"]) or ("chinese" indf["CUISINE DESCRIPTION"]):
DBA += df["DBA"]
pieplot = plt.pie(cuisine_types,labels="Cuisine Types")
t = plt.title("Number of SAT takers per borough") #don't have tosave to variable
In Python, I am analyzing a dataset about health inspections in New York to make the conclusion on whether burgers, pizz
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
In Python, I am analyzing a dataset about health inspections in New York to make the conclusion on whether burgers, pizz
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!