Question

In: Computer Science

***PYTHON*** CSV: OrderDate Region Rep Item Units Unit Cost Total 9/1/2014 Central Smith Desk 2 125...

***PYTHON***

CSV:

OrderDate Region Rep Item Units Unit Cost Total
9/1/2014 Central Smith Desk 2 125 250
6/17/2015 Central Kivell Desk 5 125 625
9/10/2015 Central Gill Pencil 7 1.29 9.03
11/17/2015 Central Jardine Binder 11 4.99 54.89
10/31/2015 Central Andrews Pencil 14 1.29 18.06
2/26/2014 Central Gill Pen 27 19.99 539.73
10/5/2014 Central Morgan Binder 28 8.99 251.72
12/21/2015 Central Andrews Binder 28 4.99 139.72
2/9/2014 Central Jardine Pencil 36 4.99 179.64
8/7/2015 Central Kivell Pen Set 42 23.95 1,005.90
1/15/2015 Central Gill Binder 46 8.99 413.54
1/23/2014 Central Kivell Binder 50 19.99 999.5
9/27/2015 West Sorvino Pen 76 1.99 151.24
Mean 48.97619 20.3086 443.0819
Median 51.5 4.99 255.84
Mode 7 4.99 449.1

Using Python and Pandas complete the following questions:

  1. Import the CSV in python
  2. Create a new variable (column), which is the ratio of Unit Cost divided by Total. Title this variable Cost Total Ratio.
  3. Print the new variable values.

The CSV data is provided above. Please use pandas and python for this question and provide the code.

Solutions

Expert Solution

The program is given below:

a) below code is used to import csv in python

import pandas as pd
#import the CSV in python
df = pd.read_csv (r'read_data.csv')
df1=df.head(13)
print(df1)

The read_data.csv

OrderDate Region Rep Item Units Unit Cost Total
09-01-2014 Central Smith Desk 2 125 250
6/17/2015 Central Kivell Desk 5 125 625
09-10-2015 Central Gill Pencil 7 1.29 9.03
11/17/2015 Central Jardine Binder 11 4.99 54.89
10/31/2015 Central Andrews Pencil 14 1.29 18.06
2/26/2014 Central Gill Pen 27 19.99 539.73
10-05-2014 Central Morgan Binder 28 8.99 251.72
12/21/2015 Central Andrews Binder 28 4.99 139.72
02-09-2014 Central Jardine Pencil 36 4.99 179.64
08-07-2015 Central Kivell Pen Set 42 23.95 1,005.90
1/15/2015 Central Gill Binder 46 8.99 413.54
1/23/2014 Central Kivell Binder 50 19.99 999.5
9/27/2015 West Sorvino Pen 76 1.99 151.24
Mean 48.976 20.309 443.082
Median 51.5 4.99 255.84
Mode 7 4.99 499.1

Output:

b) below code is used to create a new variable (column), which is the ratio of Unit Cost divided by Total.

#create a new variable(column), which is the ratio of Unit Cost divided by Total.
Cost_total_ratio=[]
for index, row in df1.iterrows():
a=(float(row["Unit Cost"]))
b=float(float(row["Total"].replace(',','')))
Cost_total_ratio.insert(index,a/b)

df1['Cost Total Ratio'] = Cost_total_ratio

c) The below code is used to Print the new variable(Cost Total Ratio) values.

df1['Cost Total Ratio']

Output:


Related Solutions

Question (2) Units Unit Cost ($) Total Jan. 1 (Beg.)          100                  15    
Question (2) Units Unit Cost ($) Total Jan. 1 (Beg.)          100                  15       1,500 Jan. 15 Purchase            100                  20       2,000 Jan. 20 Purchase            200                  25       5,000 Jan. 25 Purchase            150                  30       4,500 Total          550     13,000 Jan. 30 Sold          220 Selling Price ($)             50 Required: Assume ABC uses the Weighted – Average method calculate I-ending inventory, II-cost of goods sold andIII-gross profit.   Assume ABC uses LIFOmethod calculate I-ending inventory, II-cost of goods sold andIII-gross profit.  
Date Transaction Units In Unit Cost Total Units Sold Sales Price Total 7/1 Balance 100 4.10...
Date Transaction Units In Unit Cost Total Units Sold Sales Price Total 7/1 Balance 100 4.10 410 7/6 Purchase 800 4.20 3,360 7/7 Sale 300 7.00 2,100 7/10 Sale 300 7.30 2,190 7/12 Purchase 400 4.50 1,800 7/15 Sale 200 7.40 1,480 7/18 Purchase 300 4.60 1,380 7/22 Sale 400 7.40 2,960 7/25 Purchase 500 4.58 2,290 7/30 Sale 200 7.50 1,500 Totals 2,100 9,240 1,400 10,230 Compute FIFO, LIFO, Average for the perpetual inventory system. Be sure to do...
Date Transaction Units In Unit Cost Total Units Sold Sales Price Total 7/1 Balance 100 4.10...
Date Transaction Units In Unit Cost Total Units Sold Sales Price Total 7/1 Balance 100 4.10 410 7/6 Purchase 800 4.20 3,360 7/7 Sale 300 7.00 2,100 7/10 Sale 300 7.30 2,190 7/12 Purchase 400 4.50 1,800 7/15 Sale 200 7.40 1,480 7/18 Purchase 300 4.60 1,380 7/22 Sale 400 7.40 2,960 7/25 Purchase 500 4.58 2,290 7/30 Sale 200 7.50 1,500 Totals 2,100 9,240 1,400 10,230 Compute FIFO, LIFO, Average for the periodic inventory system. Be sure to do...
The records of ABC Company showed the following: Units Unit Cost Total Cost January 1 Beginning...
The records of ABC Company showed the following: Units Unit Cost Total Cost January 1 Beginning 10,000 60 600,000 April 1 Purchase 18,000 50 900,000 October 1 Purchase 22,000 40 880,000 The physical inventory reveals 15,000 units on hand on December 31. Compute the cost of ending inventory and cost of sales using: Inventory Cost Flow Ending Inventory Cost of Goods Sold (COGS) First in, first out (FIFO) Weighted Average Last in, first out (LIFO)
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is...
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is $12, marginal cost is $9, and average variable cost is $9.50. What should the firm do and why? D. Continue to produce because price can be increased A. Continue to operate and reduce costs to earn a profit C. Shut down because the price is less than the average variable cost B. Shut down because the firm’s earning a loss of $15.00 2. For...
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is...
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is $15, marginal cost is $9, and average variable cost is $7.50. What should the firm do and why? A. Shut down, because average total cost is greater than price B. Shut down, because of a loss of $5,000 D. Continue to produce, because price is greater than average total cost C. Continue to produce, because price is greater than average variable cost 2. The...
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is...
1. Assume the following: sales price is $9, output is 5,000 units, average total cost is $15, marginal cost is $9, and average variable cost is $7.50. What should the firm do and why? A. Shut down, because average total cost is greater than price B. Shut down, because of a loss of $5,000 C. Continue to produce, because price is greater than average variable cost D. Continue to produce, because price is greater than average total cost 2.The price...
Hermione Co. reported the information shown in Table 5-1. Table 5-1 Units Unit Cost Total Cost...
Hermione Co. reported the information shown in Table 5-1. Table 5-1 Units Unit Cost Total Cost Units Sold Beginning inventory (Jan. 1)            4      $400     $1,600 Sale (Mar. 1)             3 Purchase (Apr. 15)            4        405       1,620 Sale (June 22)             3 Purchase (Oct. 11)           2        425         850                  Total    Units in ending inventory          10            4     $4,070             6 10.       Refer to Table 5-1. Assume that...
Data: Date Item Units Cost per unit Dec. 1 Inventory 30 $12 Dec. 10 Purchase 60...
Data: Date Item Units Cost per unit Dec. 1 Inventory 30 $12 Dec. 10 Purchase 60 $13 Dec. 20 Purchase 40 $14 Dec. 12 Sale 40 Dec. 27 Sale 15 Required: (1) Find the ending inventory and the cost of goods sold for December under the periodic inventory system using the following inventory costing methods. (a) average cost (b) FIFO (2) Also find ending inventory and the cost of goods sold for the month of December under the perpetual inventory...
Beginning Inventory # of units Cost per unit Total Beginning Inventory 15 $10 $150 Jan 1....
Beginning Inventory # of units Cost per unit Total Beginning Inventory 15 $10 $150 Jan 1. Purchase 15 $11 $165 Jan 10. Purchase 15 $12 $180 Total 45 1. During January, AA sold 20 units at $30 per unit. Under FIFO, how much is the Gross Profit? $365 $380 $390 $395 2. During January, AA sold 20 units at $30 per unit Under the Weighted Average Method, how much is the Gross Profit?. $365 $380 $395 $400 3. During January,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT