Question: import matplotlib.pyplot as plt # Create a DataFrame with the provided data data = { 'Date': [ '01/01/2023', '02/01/2023', '03/01/2023', '04/01/2023', '05/01/2023', # Add the

import matplotlib.pyplot as plt


# Create a DataFrame with the provided data

data = {

'Date': [

'01/01/2023', '02/01/2023', '03/01/2023', '04/01/2023', '05/01/2023',

# Add the rest of the dates...

],

'Batches Tested': [

50, 48, 52, 47, 49,

# Add the rest of the data...

],

'Batches Failed': [

2, 1, 3, 2, 3,

# Add the rest of the data...

],

'Successful Batches': [

48, 47, 49, 45, 46,

# Add the rest of the data...

]

}


# Create a new column for failed batches

data['Failed Batches'] = data['Batches Tested'] - data['Successful Batches']


# Calculate the total number of failed and successful batches

total_failed = sum(data['Failed Batches'])

total_successful = sum(data['Successful Batches'])


# Create a pie chart

labels = ['Failed Batches', 'Successful Batches']

sizes = [total_failed, total_successful]

colors = ['red', 'green']


plt.figure(figsize=(8, 8))

plt.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140)


# Add title

plt.title('Composition of Failed Batches to Successful Batches')


# Show the chart

plt.show()

Step by Step Solution

3.48 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer The provided Python code utilizes Matplotlib to create a pie chart illustrating the compositi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!