Question

1. First, create a Pandas data frame looks as following: Name Product Amount 0 Bob apple...

1. First, create a Pandas data frame looks as following:

Name Product Amount

0 Bob apple 1

1 Bob banana 2

2 jessica orange 3

3 jessica banana 4

4 jessica tomato 3

5 mary banana 2

6 john apple 3

7 john grape 1

Second, find out for each product, how many were sold (for example, 4 units of Apple were sold). Third, which products sales are larger than 3 (for example, apple sold more than 3 units)

PYTHON

Homework Answers

Answer #1

STEP - BY - STEP PROCESS

(i) Create a Pandas data frame:

import pandas as pd
Name = pd.Series(['Bob', 'Bob', 'Jessica', 'Jessica', 'Jessica', 'Mary', 'John', 'John'])
Product = pd.Series(['Apple', 'Banana', 'Orange', 'Banana', 'Tomato', 'Banana', 'Apple', 'Grape'])
Amount = pd.Series([1, 2, 3, 4, 3, 2, 3, 1])

df = pd.DataFrame([Name, Product, Amount], index=['Name', 'Product', 'Amount']).T
df

(ii) Find out for each product, how many were sold:

df1 = df.groupby(['Product'])['Amount'].agg('sum')
df1

(iii) Find which products sales are larger than 3:

df1[df1 > 3]

Thumbs Up Please !!!

Know the answer?
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
Similar Questions
-- Define the database CREATE TABLE Product ( ProdName VARCHAR2(10) NOT NULL, Price INTEGER NOT NULL,...
-- Define the database CREATE TABLE Product ( ProdName VARCHAR2(10) NOT NULL, Price INTEGER NOT NULL, CONSTRAINT PRODUCT_PK PRIMARY KEY (ProdName) ); CREATE TABLE Customer ( ID INTEGER NOT NULL, ProdName VARCHAR2(10), Rating INTEGER, CustName VARCHAR2(10), CONSTRAINT CUSTOMER_PK PRIMARY KEY (ID) ); CREATE TABLE Buys ( ID INTEGER NOT NULL, ProdName VARCHAR2(10) NOT NULL, Quantity INTEGER NOT NULL, CONSTRAINT BUYS_PK PRIMARY KEY (ID, ProdName) ); ALTER TABLE Buys ADD CONSTRAINT PRODUCT_BUYS_FK FOREIGN KEY (ProdName) REFERENCES Product (ProdName) NOT DEFERRABLE; ALTER...
Python 3 We’re going to create a class which stores information about product ratings on a...
Python 3 We’re going to create a class which stores information about product ratings on a website such as Amazon. The ratings are all numbers between 1 and 5 and represent a number of “stars” that the customer gives to the product. We will store this information as a list of integers which is maintained inside the class StarRatings. You will be asked to write the following: 1) A constructor which takes and stores the product name. 2) A function...
1. THE FOLLOWING INFORMATION IS USED FOR QUESTIONS 1 – 10. Quiz Company sells its product...
1. THE FOLLOWING INFORMATION IS USED FOR QUESTIONS 1 – 10. Quiz Company sells its product for $10 per unit. Variable costs are $6 per unit and fixed costs are $15,000 per week. During the third week of July, Quiz Company sold 5,000 units. Determine the total contribution margin for the week. 2. Determine the operating income for the week. 3. Determine the contribution margin ratio. 4. Determine the number of units Quiz Company must sell to break even. 5....
Case Study #1: Planning a Healthy Vegetarian Diet Name: ________________________________ Please - put your name in...
Case Study #1: Planning a Healthy Vegetarian Diet Name: ________________________________ Please - put your name in the title of each document! Instructions: There are 4 parts to this case study. Read through the case below and then use the suggested resources to complete all 4 parts to submit by Wednesday of week 4. Then, using any feedback or additional insight from the week, make any necessary changes and submit a second version by the end of week 4. Post and...
Elliot Co. manufactures a product with seasonal variations in demand. The following budget data for this...
Elliot Co. manufactures a product with seasonal variations in demand. The following budget data for this product has been collected for the upcoming year (2014).   In addition, predictions were also made for the first quarter of 2015. 2014 Quarter 1 Quarter 2 Quarter 3 Quarter 4 -Forecasted sales in units: 40,000 60,000 100,000 50,000 -Forecasted sales in units for the first quarter of 2015: 70,000 -Sales price per unit $8.00 -Desired ending inventory of finished units as a percentage of...
Elliot Co. manufactures a product with seasonal variations in demand. The following budget data for this...
Elliot Co. manufactures a product with seasonal variations in demand. The following budget data for this product has been collected for the upcoming year (2014).   In addition, predictions were also made for the first quarter of 2015. 2014 Quarter 1 Quarter 2 Quarter 3 Quarter 4 -Forecasted sales in units: 40,000 60,000 100,000 50,000 -Forecasted sales in units for the first quarter of 2015: 70,000 -Sales price per unit $8.00 -Desired ending inventory of finished units as a percentage of...
1: Gabuat Corporation, which has only one product, has provided the following data concerning its most...
1: Gabuat Corporation, which has only one product, has provided the following data concerning its most recent month of operations: Selling price $ 138 Units in beginning inventory 0 Units produced 2,600 Units sold 2,310 Units in ending inventory 290 Variable costs per unit: Direct materials $ 49 Direct labor $ 27 Variable manufacturing overhead $ 6 Variable selling and administrative expense $ 6 Fixed costs: Fixed manufacturing overhead $36,400 Fixed selling and administrative expense $13,860 The total gross margin...
1) Cincinnati Supply Corp. has supplied the following data on its organic fertilizer product: Bags produced...
1) Cincinnati Supply Corp. has supplied the following data on its organic fertilizer product: Bags produced and sold: 240,000 units Sales revenue: $1,896,000 Variable manufacturing expenses: $804,000 Fixed manufacturing expense: $520,000 Variable selling and administrative expense: $180,000 Fixed selling and administrative expense: $270,000 Net operating income: $122,000 The company's per unit contribution margin is closest to: a).$3.80 per unit b).$7.15 per unit c).$4.55 per unit d).$4.10 per unit 2).Cincinnati Supply Corp., a supplier to Kraft Foods, produces and sells a...
Question 1 The following are common characteristics of Economic Models, EXCEPT: a)They represent a simplification of...
Question 1 The following are common characteristics of Economic Models, EXCEPT: a)They represent a simplification of the complex reality. b)They use concept to convey key ideas c)They use assumptions that are fully realistic d)They often use graphical analysis. Question 2 The following are correct statements about the Production Possibility Frontier model, EXCEPT: a) Is the graphical representation of the maximum output attainable given certain inputs, for any given economy or entity. b) Any point on the PPF is Efficient c)...
1. Over-applied overhead that is material in amount is allocated between Finished Goods inventory, Work in...
1. Over-applied overhead that is material in amount is allocated between Finished Goods inventory, Work in process Inventory and Cost of Goods sold at year end. Over-applied factory overhead that is immaterial in amount is closed to Cost of Goods Sold at year end. First and second sentence are true First and second sentence are false Only the first statement is true Only the second statement is true 2. Process costing is most appropriate when manufacturing large batches of homogeneous...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT