Question
can you please provide the code for printing the date in below format { 'Ride1' : {min : 1, max : 3, avg : 2
can you please provide the code for printing the date in below format
{ 'Ride1' : {min : 1, max : 3, avg : 2 }, 'Ride2' :{ min : 1, max : 3, avg : 2 } ... }
my code
r.execute("SELECT AttractionID, Name FROM attraction WHERE Category LIKE '%ride%'") name_ids = r.fetchall() result_mat ={} total_count = {} for id_attraction, name in name_ids: result_mat[id_attraction] = {} result_mat[id_attraction]["name"] = name result_mat[id_attraction]["min"] = float('inf') result_mat[id_attraction]["max"] = 1 result_mat[id_attraction]["avg"] = 0 r.execute("SELECT sequence FROM sequences") sequences = r.fetchall() executed_sequence = [] for tupl in sequences: executed_sequence.append(tupl[0].split("-")) for j in range(576): p = {} for i in range(len(executed_sequence)): c = int(executed_sequence[i][j]) if c not in p: p[c] = 0 p[c] += 1 for key in result_mat.keys(): if key in p: result_mat[key]["avg"] += p[key] result_mat[key]["min"] = min(result_mat[key]["min"], p[key]) result_mat[key]["max"] = max(result_mat[key]["max"], p[key]) for key in result_mat.keys(): if result_mat[key]["min"] == float('inf'): result_mat[key]["min"] = 1 result_mat[key]["avg"] = result_mat[key]["avg"] / 576
AttractionDF = pd.DataFrame.from_dict(result_mat, orient='index', columns = ["name", "min", "avg", "max"]) #parallel_coordinates(AttractionDF, "name") parallel_coordinates(AttractionDF, "name") plt.title('Ride Attendance - Minimum, Maximum, Average') plt.ylabel('Attendance') plt.gca().legend_.remove()
plt.show()
print(AttractionDF)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started