Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Algorithms questions

Question

2. Which animal species would have the longest axonspg109

Answered: 1 week ago