Question
using python programming language, find the following
Table 2 Parts Current Inventory Part 1 20 Part2 3 0 Part 3 100 Part 4 50 Part 5 90 Table 1 Suppliers Defective Rate (%) Suppl
Task Read data in Table 1 using openpyxl and draw a bar chart using matplotlib. Read data in Table 2 using openpyxl and draw
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#import the libraries
import matplotlib.pyplot as plt
import numpy as np

from openpyxl import load_workbook

#load workbook
wb = load_workbook('Table1.xlsx')
#first sheet name extracted
sheet = wb.sheetnames[0];
ws = wb[sheet];
suppliers=[];
#get suppliers name ... exclude attributes name
for i in ws['A'][1:]: # ws['A'] is column A and [1:] excludes first value
    suppliers.append(i.value);
  
  
dRate=[];
#get defective rate
for i in ws['B'][1:]: # column 2 with attribute value exluded
    dRate.append(i.value);


index = np.arange(len(suppliers)) # create an array of [1,.....len(suppliers)]


plt.bar(index, dRate) #craete the bar

plt.xlabel(ws['A1'].value, fontsize=5) # label s axis
plt.ylabel(ws['B1'].value, fontsize=5) # label y axis
plt.xticks(index, suppliers, fontsize=5, rotation=30) # xticks on the x axis
plt.title('Defective Rate(%) for each supplier') # title
plt.show()


#--------------------------------------------------------------------------


wb2 = load_workbook('Table2.xlsx')
sheet = wb2.sheetnames[0];
ws2 = wb2[sheet];

parts =[];
for i in ws2['1'][1:]: # get row 1 with 1st column excluded
    parts.append(i.value);
  
inventories = [];
for i in ws2['2'][1:]: # get row 2 with 1st column excluded
    inventories.append(i.value);
explode = np.zeros(len(parts));     # make a row vector with all zero of size equal to total parts
explode[1]=0.2;                     # explode value for part2 set to 0.2 instead of 0
fig1, ax1 = plt.subplots()

#pie chart plotted with given explode value and labels as parts with startangle of 90
ax1.pie(inventories, explode=explode, labels=parts, autopct='%1.1f%%',
        shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.

plt.show()

=========================================================

import matplotlib.pyplot as plt import numpy as np from openpyxl import load_workbook #load workbook wb = load_workbook(Tabl

wb2 = load_workbook (Table2.xlsx) sheet = wb2.sheetnames[0]; WS2 = wb2[sheet]; parts =[]); for i in ws2[1][1:]: # get row

The output bar chart and pie chart are :--

Defective Rate(%) for each supplier Part 1 Part2 10.3% 6.9% Part5 31.0% 34.5% 17.2% Part3 Part4

Thanks

import matplotlib.pyplot as plt import numpy as np from openpyxl import load_workbook #load workbook wb = load_workbook('Table1.xlsx') #first sheet name extracted sheet = wb. sheetnames[0]; WS = wb[ sheet]; suppliers=[]; #get suppliers name ... exclude attributes name for i in ws['A'][1:]: # ws['A') is column A and [1:] excludes first value suppliers.append(i.value); dRate=[]; #get defective rate for i in ws['B'][1:]: # column 2 with attribute value exluded dRate.append(i.value); index = np.arange(len(suppliers)) # create an array of (1, ..... Zen(suppliers plt.bar(index, dRate) #craete the bar plt.xlabel(ws['A1'].value, fontsize=5) # label s axis plt.ylabel(ws['B1'].value, fontsize=5) # label y axis plt.xticks(index, suppliers, fontsize=5, rotation=30) # xticks on the x axis plt.title('Defective Rate(%) for each supplier') # title plt.show()

wb2 = load_workbook ('Table2.xlsx') sheet = wb2.sheetnames[0]; WS2 = wb2[sheet]; parts =[]); for i in ws2['1'][1:]: # get row 1 with 1st column excluded parts.append(i.value); inventories = []; for i in ws2['2'][1:]: # get row 2 with 1st column excluded inventories.append(i.value); explode = np.zeros(len(parts)); # make a row vector with all zero of size equal t explode[1]=0.2; # explode value for part2 set to 0.2 instead of 6 figi, ax1 = plt.subplots() #pie chart plotted with given explode value and Labels as parts with startangle of 90 ax1.pie(inventories, explode=explode, labels=parts, autopct='%1.1f%%', shadow=True, startangle=90) ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. plt.show()

Defective Rate(%) for each supplier Part 1 Part2 10.3% 6.9% Part5 31.0% 34.5% 17.2% Part3 Part4

Add a comment
Know the answer?
Add Answer to:
using python programming language, find the following Table 2 Parts Current Inventory Part 1 20 Part2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from...

    Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from number #1 link provided for the Data: -----> https://docs.google.com/spreadsheets/d/1TqhyxFKQlOHAyXpQBL-4C96kgZFBoMwUgE8-b33CqPQ/edit?usp=sharing PROBLEMS # 0.0 Import the libraries (pandas, matplotlib, and seaborn) Include the code line: %matplotlib inline #Include the code line: plt.style.use(“ggplot”) #Load the data using pandas #Inspect the data using head(), dtypes ANSWERD: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.style.use('ggplot') %matplotlib inline df = pd.read_csv() print(df.head()) print(df.dtypes) # 1...

  • Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test...

    Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_matrix_char(matrix): Prints the contents of a 2D list of strings in a formatted table. Prints row and column headings. Use: print_matrix_char (matrix) Parameters: matrix - a 2D list of strings (2D list) Returns: None. Sample testing: Number of rows: 3 Number of columns: 4 0 1 2 3 i 0 с u r 1 с у...

  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

  • Please finish all 6 parts with indexing SQL. Don't need to do the measure time things, but you can do it if you wanna do it. Thanks! Write the following SQL queries and measure their execution t...

    Please finish all 6 parts with indexing SQL. Don't need to do the measure time things, but you can do it if you wanna do it. Thanks! Write the following SQL queries and measure their execution time both with and without using indexes 1. Count how many parts in NYC have more than 70 parts on hand 2. Count how many total parts on hand, in both NYC and SFO, are Red 3. List all the suppliers that have more...

  • OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a...

    OBJECT ORIENTED PROGRAMMING C++ B- The programming section has 2 parts: Part 1 - Create a class - (35 points) Create a class called CustomDressInvoice. It should have 5 data members: designTime (int), designRate (int), sewing Time (int), sewingRate (int), and materialsCost. The invoice amount is calculated with this formula: Invoice Amount = (designTime * designRate) + (sewingTime * sewing Rate) + materialCost All times are charged by the hours, and rates are charged by the dollars (no cents). The...

  • USING PYTHON LANGUAGE. QUESTION I: Write a program that displays the following table: a a^2 a...

    USING PYTHON LANGUAGE. QUESTION I: Write a program that displays the following table: a a^2 a 3 a14 1 1 1 1 2 4 8 16 3 9 27 81 4 16 64 256 QUESTION II: An approximate value of a number can be computed using the following formula: 7 ) Write a program that displays the result of 4 X + 7 • H) and 4 X - 를 7 tis). 9 QUESTION III: Write a program that prompts...

  • Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate)...

    Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate) Question 1 options: Python A C-based language FORTRAN COBOL Question 2 One of my favorite quotes from Jeanette Wind is "Computational thinking is using abstraction and decomposition when attacking a large complex task or designing a large complex system." This supports using _____________ when developing programs. Question 2 options: Repetition structures Assignment statements Selection structures Functions Question 3 The following assignment statement exhibits which...

  • The programming language is C# we are using wpf forms. Hello, I would like to get...

    The programming language is C# we are using wpf forms. Hello, I would like to get my clear button to work. So when clear is click everything is clear not only the total, tax or subtotal but also the combox and the data grid. For the Delete button if the user selects a specific item it will be deleted and for the receipt button, it should create a pdf that contains the Name, Price, quantity, tax, total and subtotal. it...

  • Need a program in python. Asterix and Obelix want to store and process information about movies...

    Need a program in python. Asterix and Obelix want to store and process information about movies they are interested in. So, you have been commissioned to write a program in Python to automate this. Since they are not very computer literate, your program must be easy for them to use. They want to store the information in a comma separated text file. Using this they would need to generate a report – see all items AND show a bar chart...

  • help Assignment Chapter 13 1. Ten samples of 20 parts each were taken from an ongoing...

    help Assignment Chapter 13 1. Ten samples of 20 parts each were taken from an ongoing process to establish a p-chart for control. The samples and the number of defectives in each are shown in the following table: # DEFECTIVE ITEMS IN # DEFECTIVE ITEMS IN MPLESAMPLE SIZETHE SAMPLE SAMPLE SAMPLE SIZE SAMPLE 20 20 20 20 20 20 20 20 20 10 a. Develop a p-chart using z-3. (3 pts) b. Based on the plotted data points, is the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT