Question

In: Computer Science

Type the Python code for all the questions. 1 2 Q1: Using DataFrame, with Figure 1...

Type the Python code for all the questions. 1 2 Q1: Using DataFrame, with Figure 1 data, store the hypermarket data for rows and columns. Display the output as shown in Figure 1. 0 ITEMS NAME DISCOUNT 1 Grocery Rice 56 2 Electronics Mobile 25% 3 Food Apple 30% Figure 1 Q2: Update and display the "Rice" discount from 5% to 10%. Your output should be like Figure 2 now. 1 2 0 ITEMS NAME DISCOUNT 1 Grocery Rice 108 2 Electronics Mobile 25% 3 Food Apple 30% Figure 2 NO Q3: Use Figure 3 data to add and display a new column. Your output should be like Figure 3 now. 0 1 2 3 ITEMS NAME DISCOUNT STOCK Grocery Rice 10% 100 Electronics Mobile 25% 3 Food Apple 30% W NO 20 40 Figure 3

Solutions

Expert Solution

CODE:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np


data = [['Grocery', 'Rice', '5%'], ['Electronics', 'Mobile', '25%'],
['Food', 'Apple', '30%']]
  
df = pd.DataFrame(data, columns = ['ITEMS', 'NAME', 'DISCOUNT'])
  
# print dataframe.

print(df)
df.loc[df['NAME'] == 'Rice', 'DISCOUNT']='10%'
print(df)
stock=[100,3,20]
df['STOCK']=stock
print(df)

OUTPUT:

If you have any doubts please COMMENT....

If you understand the answer please give THUMBS UP....


Related Solutions

Using the first code of this lab (Figure 1), write a code that displays the status...
Using the first code of this lab (Figure 1), write a code that displays the status of a push button on the LCD, that is, when you press it you should see “Pushed” on the LCD and when you release it, you should see “Released” #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2);...
In the figure particle 1 of charge q1 = 0.93 μC and particle 2 of charge...
In the figure particle 1 of charge q1 = 0.93 μC and particle 2 of charge q2 = -2.96 μC, are held at separation L = 9.5 cm on an x axis. If particle 3 of unknown charge q3 is to be located such that the net electrostatic force on it from particles 1 and 2 is zero, what must be the (a)x and (b)y coordinates of particle 3?
Make sure all figures are clearly labeled (e.g., Figure 1, Figure 2, etc.), and include all...
Make sure all figures are clearly labeled (e.g., Figure 1, Figure 2, etc.), and include all R code used to answer questions. Simulating from distributions For each of the following subproblems: i. Plot the distribution you’re sampling from (e.g., if Xi∼Exp(λ), plot the exponential distribution with rate λ ii. Generate a sample of size n= 10 from the distribution, and find the sample mean. iii. Repeat step ii. 999 times (i.e.,k= 1000), and then plot a histogram of the samples....
USE PYTHON-LIST Q1 - You need to keep track of book titles. Write code using function(s)...
USE PYTHON-LIST Q1 - You need to keep track of book titles. Write code using function(s) that will allow the user to do the following. 1. Add book titles to the list. 2. Delete book titles anywhere in the list by value. 3. Delete a book by position. Note: if you wish to display the booklist as a vertical number booklist , that is ok (that is also a hint) 4. Insert book titles anywhere in the list. 5. Clear...
All code should be in Python 3. Implement the Stack Class, using the push, pop, str,...
All code should be in Python 3. Implement the Stack Class, using the push, pop, str, init methods, and the insurance variable 'list'.
Use Python to solve: show all code: 2) For the last assignment you had to write...
Use Python to solve: show all code: 2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. The program output looked like this: Balance after year 1 is $ 1060.0 Balance after year 2 is $ 1123.6 Balance after year 3 is $ 1191.02 Balance after year 4 is $ 1262.48 Balance after...
Using the python program language. Expand/EDIT the code below for all vowels (AEIOU). Please provide a...
Using the python program language. Expand/EDIT the code below for all vowels (AEIOU). Please provide a code and a screen shot of the code working with an output. the code should be able to take any name as an  input. The code should be able to pull out the vowels along with the count fo each vowel within that name for the output. #countVowels.py import sys s1 = str(sys.argv[1]) (a,e,i,o,u) = (0,0,0,0,0) print ("String length = ", len(s1)) for n in...
C++ Code Using all for loops 1. Print 5 lines with 1 asterisk per line 2....
C++ Code Using all for loops 1. Print 5 lines with 1 asterisk per line 2. Print 5 asterisk on 1 line. Endl at the end of the line. 3. Ask for a positive # and print that many asterik on the next line. 4. Using 2 for loops one inside of another that only prints 1 asterik, print a hill shaped triangle: Ex( Input a number a: 4 * ** *** **** 5. Change the for statements to print...
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs....
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs. Create a GUI Calculator with the following: Title : Calculator Label and Entry box for 1st Number Label and Entry box for 2nd Number Buttons for *, /, +, - Label for result and Displaying the result
1. Using the following code identify the fault. 2. Using the following code indentify a test...
1. Using the following code identify the fault. 2. Using the following code indentify a test case that results in an error, but not a failure. public static int lastZero (int[] x) { //Effects: if x == null throw NullPointerException //else return the index of the last 0 in x. //Return -1 if 0 does not occur in x for (int i = 0; i < x.length; i++) { if (x[i] == 0) { return i; } } return -1;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT