Question

In: Computer Science

The following is a preview of the dataframe products: item cost profit sold_out 1 A 46...

The following is a preview of the dataframe products:

  item cost profit sold_out
1    A   46     15    FALSE
2    B   50      5     TRUE
3    C   28     10    FALSE
4    D   38     12    FALSE
5    E   20      5     TRUE

Write the code that returns the items with profit equal or greater than 12:

Output:
  item cost profit sold_out
1    A   46     15    FALSE
4    D   38     12    FALSE

Solutions

Expert Solution

import pandas as pd

# creating products dictionary
data = {
    'item': ['A' ,'B' ,'C' ,'D' ,'E'],
    'cost': [46 ,50 ,28 ,38 ,20],
    'profit': [15 ,5 ,10 ,12 ,5],
    'sold_out': [False ,True ,False ,False ,True]
}

# converting data dictionary to dataframe
products = pd.DataFrame(data)

# actual indexes start from 0
# we have to increase by 1
products.index = products.index + 1
print("Preview of products : \n")
# printing dataframe
print(products)
print("------------------------------------\n")

print("Products with Profit >= 12 : \n")
# products.profit >= 12
# checks all the profits and returns a list of
# True and False based on that outer products will display
# whole data of products with profit >= 12
print(products[products.profit>=12])

Code :

Output :


Related Solutions

Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30...
Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30 seconds 00:46:30 On Dec 31, 20X2, the end of the year, Schubert Co. had the following stockholders’ equity. You have been given the ending balances for the year and asked to compute the balances as of the beginning of the year. 9% Preferred Stock, $40 par $   600,000 Common Stock, $8 par $   960,000 Add’l PIC $1,355,000 Retained Earnings $1,255,000 Treasury Stock, 4,000 shares...
Accessories department reported the following: Cost of Goods Sold.. $245,000 Gross Margin.. 46% Net Profit.. 3%...
Accessories department reported the following: Cost of Goods Sold.. $245,000 Gross Margin.. 46% Net Profit.. 3% What is the “$ Net Sales” and “$ Operating Expenses”? A. $453,704 Net Sales; $195,093 Operating Expenses B. $36,296 Net Sales; $208,704 Operating Expenses C. $403,797 Net Sales; $208,704 Operating Expenses D. $13,611 Net Sales; $195,093 Operating Expenses
1. A company wishes to estimate the profit from two new products. The estimated cost of...
1. A company wishes to estimate the profit from two new products. The estimated cost of producing the first product is €3 per unit and it is expected to sell for €5 per unit while the second product costs €5 per unit and is expected to sell for €8 per unit. The first product takes 1 hour of packaging time per day while the second one takes 2 hours of packaging time per day. The time taken for delivery of...
Perform ABC analysis for the following products: Item Volume (units/ year) Cost ($/unit) Annual $ Volume...
Perform ABC analysis for the following products: Item Volume (units/ year) Cost ($/unit) Annual $ Volume A 700 1 700 B 70 15 1050 C 965 4 3860 D 514 5 2570 E 20 15 300 F 770 32 24640 G 608 29 17632 H 513 2 1026 I 578 10 5780 J 199 2 398 57956 please, try to explain how can get the answer without used excel
The profit function for two products is:     Profit = −3x 12 + 42x 1 − 3x...
The profit function for two products is:     Profit = −3x 12 + 42x 1 − 3x 22 + 48x 2 + 700, where x 1 represents units of production of product 1, and x 2 represents units of production of product 2. Producing one unit of product 1 requires 5 labor-hours, and producing one unit of product 2 requires 6 labor-hours. Currently, 24 labor-hours are available. The cost of labor-hours is already factored into the profit function, but it is...
The following pertain to the cost of H’s only inventory item: Inventory on hand, January 1                           &
The following pertain to the cost of H’s only inventory item: Inventory on hand, January 1                                                 295 units @ $50 per unit Purchases, January 12                                                            590 units @ $88 per unit Purchases, January 20                                                             450 units @ $91 per unit Purchases, January 31                                                            300 units @ $93 per unit 1,635 Sales, January 5                                                                         75 units @ $200 per unit Sales, January 15                                                                     350 units @ $200 per unit Sales, January 22                                                                     550 units @ $200 per unit Sales, January 30                                                                     140 units @ $200 per unit 1,115                                          (1,115 x...
question 1 In the datasets package, there is a dataframe ChickWeight. The weights of the chicks...
question 1 In the datasets package, there is a dataframe ChickWeight. The weights of the chicks are recorded in gram and the variable time is measured in days. Run a regression model to show how the passage of time influences the weight of the chicks. Based on the regression results, which of the following are true?(choose all correct) a.The chicks weigh about 27 grams when they hatch. b.We accept the null hypothesis that time has no effect on the weight...
The following pertain to the cost of H’s only inventory item: Inventory on hand, January 1                           &n
The following pertain to the cost of H’s only inventory item: Inventory on hand, January 1                                                10 units @ $  9 per unit Purchases, January 2                                                             150 units @ $14 per unit Purchases, January 12                                                         195 units @ $15 per unit Purchases, January 16                                                           75 units @ $15 per unit Purchases, January 20                                                            50 units @ $16 per unit Purchases, January 26                                                          205 units @ $19 per unit 685 Sales during January totaled 615 units. Each unit sold for $40. Calculate COGS AND GP for January AND...
Consider a basic economic order quantity (EOQ) model with the following characteristics: Item cost: $15 Item...
Consider a basic economic order quantity (EOQ) model with the following characteristics: Item cost: $15 Item selling price: $20 Monthly demand: 500 units (constant) Annual holding cost: $1.35 per unit Cost per order: $18 Order lead time: 5 working days Firm's work year: 300 days (50 weeks @ 6 days per week) Safety stock: 15% of monthly demand For this problem, determine the values of: Q* the optimal order quantity and reorder point. Select one: a. 400 and 100 b....
Cost Flow Methods The following three identical units of Item Alpha are purchased during April: Item...
Cost Flow Methods The following three identical units of Item Alpha are purchased during April: Item Alpha Units Cost Apr.   2 Purchase 1 $76 14 Purchase 1 81 28 Purchase 1 83 Total 3 $240 Average cost per unit $80 ($240 ÷ 3 units) Assume that one unit is sold on April 30 for $132. Determine the gross profit for April and ending inventory on April 30 using the (a) first-in, first-out (FIFO); (b) last-in, first-out (LIFO); and (c) weighted...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT