Question

Region Country Item Type Sales Channel Order Priority Order Date Order ID Ship Date Units Sold Unit Price...

Region Country Item Type Sales Channel Order Priority Order Date Order ID Ship Date Units Sold Unit Price Unit Cost Total Revenue Total Cost Total Profit
Asia Morocco Clothes Online M ######## 6.68E+08 ######## 4611 109.28 35.84 503890.1 165258.2 338631.8
Sub-Saharan Africa Ghana Office Supplies Online L ######## 6.01E+08 ######## 896 651.21 524.96 583484.2 470364.2 113120
Sub-Saharan Africa Slovakia Beverages Offline L ######## 1.75E+08 ######## 3973 47.45 31.79 188518.9 126301.7 62217.18

For this assignment you have been engaged by an e-commerce company to perform some analysis and manipulation of 500,000 records of orders from the company’s fulfillment partner. To complete the requirements of your engagement, you will create a Python program which will perform the following tasks.

The 500,000 records are provided in a comma separated value (.csv) file. Your program will read the file and create a list of records where each record is a list of fields. a. Your program must gracefully handle any file error such as the file not being present.

b. Your program will print out the following statistics about the dataset in the example format provided on the next page:

i. The record with the highest total profit including the amount, order ID, and index number in the list.

ii. The record with the lowest total profit including the amount, order ID, and index number in the list.

iii. A listing of the 10 highest total profit orders including the amount, order ID, and order date.

iv. A listing of the 10 lowest total profit orders including the amount, order ID, and order date.

c. After printing the statistics, your program will create a collection to allow for fast searching of the records by Order ID as a key and return the record if found.

i. Your program will prompt the user for an Order ID and if it is found, print the record in the example format provided on the next page.

ii. If the record is not found, an appropriate message should be printed.

iii. Your program must gracefully handle any errors and continue operation.

d. The company has a number of other systems, some of which work with objects. Your engagement contains a requirement to demonstrate the ability to create objects from the records, place them into a list, and serialize them for use as input to other programs. To do so, your program will do the following:

i. Create a class to hold the following attributes taken from each record: 1. Order ID 2. Ship Date 3. Total Profit

ii. The object will be read only and as such should provide only accessor methods. Your object must provide a __str__ method.

iii. Your program will create 100 instances for the first 100 records in the dataset.

iv. The 100 instances will be added to a list and then serialized to a file named “record_objects.dat”.

v. Your program should then deserialize the objects from file and display the 10th object in the example format provided on the next page.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer) According to the HomeworkLib policy we answer the first one. So I answer b.

For this data Analysis I use pandas in python. It is library in python which is used for data analysis. Here for the dataset the dataframe is used which is a multidimensional array list. Pandas has method which can sort,print like SQL in RDBMS. # is used for cooments

I put the code in try except block for the exception filenot found.

code starts here

import pandas as pd

try:
#dataframe created from the file.
df = pd.read_csv("C:\\python\\book1.csv")

print("i. The record with the highest total profit including the amount, order ID, and index number in the list.")

#Another dataframe created for perticular list
df1=df[['Order ID','Total Profit']]

#Another dataframe created for sorted data
df1_sorted = df1.sort_values( by ='Total Profit',ascending=False)

#head() is used to print the number of records from the top
print(df1_sorted.head(1))

print("ii. The record with the lowest total profit including the amount, order ID, and index number in the list.")

df1=df[['Order ID','Total Profit']]

df1_sorted = df1.sort_values( by ='Total Profit')

print(df1_sorted.head(1))

print("iii. A listing of the 10 highest total profit orders including the amount, order ID, and order date.")
df1=df[['Order ID','Total Profit','Order Date']]

df1_sorted = df1.sort_values( by ='Total Profit',ascending=False)

print(df1_sorted.head(10))


print("iv. A listing of the 10 lowest total profit orders including the amount, order ID, and order date.")


df1=df[['Order ID','Total Profit','Order Date']]

df1_sorted = df1.sort_values( by ='Total Profit')

print(df1_sorted.head(10))

except IOError:
print("File not found")

code end here

Output screenshot

c:\python>python ana.py i. The record with the highest total profit including the amount, order ID, and index number in the l

Add a comment
Know the answer?
Add Answer to:
Region Country Item Type Sales Channel Order Priority Order Date Order ID Ship Date Units Sold Unit Price...
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
  • Modify your program from Assignment # 7 part b (see below for code) by creating an...

    Modify your program from Assignment # 7 part b (see below for code) by creating an interactive GUI application that displays the list of the orders read in from the file (create a data file using your CreateBankFile.java program which has a least 10 bank account records in it and include it with your submission) and the total number of bank accounts. When your program starts it will first read the records from the Bank Account file (AccountRecords.txt) and creates...

  • Write a Java program in Eclipse that reads from a file, does some clean up, and...

    Write a Java program in Eclipse that reads from a file, does some clean up, and then writes the “cleaned” data to an output file. Create a class called FoodItem. This class should have the following: A field for the item’s description. A field for the item’s price. A field for the item’s expiration date. A constructor to initialize the item’s fields to specified values. Getters (Accessors) for each field. This class should implement the Comparable interface so that food...

  • A company has received an order to manufacture 75 customized units of an entertainment cabinet. The...

    A company has received an order to manufacture 75 customized units of an entertainment cabinet. The company is being offered $960 per cabinet and the CEO must decide whether or not to accept the order. An analysis of the production process for the cabinet reveals that a new, special-purpose lathe will be required. The estimated cost of the lathe is $14,400, although there is some uncertainty due to new tariffs. The variable cost is more difficult to estimate because the...

  • Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException;...

    Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class SongsReport {    public static void main(String[] args) {               //loading name of file        File file = new File("songs.csv"); //reading data from this file        //scanner to read java file        Scanner reader;        //line to get current line from the file        String line="";       ...

  • C++ Programming

    PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...

  • CS 2050 – Programming Project # 1 Due Date: Session 3 (that is, in one week!)....

    CS 2050 – Programming Project # 1 Due Date: Session 3 (that is, in one week!). Can be resubmitted up to two times until Session 6 if your first version is submitted by session 3. In this project, you create two classes for tracking students. One class is the Student class that holds student data; the other is the GradeItem class that holds data about grades that students earned in various courses. Note: the next three projects build on this...

  • Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also...

    Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also here is the address.csv file Name,Phone,Email,Year_of_Birth Elizi Moe,5208534566,[email protected],1978 Ma Ta,4345667345,[email protected],1988 Diana Cheng,5203456789,[email protected],1970 ACTIVITY I Implement in Python the Subscriber class modeled by the UML diagram provided below. Save in a file called MyClasses.py Subscriber name: string yearOfBirth: int phone: string email: string getName() getAge() getPhone() getEmail() Write a test program that does the following: Read the file addresses.csv. For each record, create an object...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

  • I am really struggling with this assignment, can anyone help? It is supposed to work with...

    I am really struggling with this assignment, can anyone help? It is supposed to work with two files, one that contains this data: 5 Christine Kim # 30.00 3 1 15 Ray Allrich # 10.25 0 0 16 Adrian Bailey # 12.50 0 0 17 Juan Gonzales # 30.00 1 1 18 J. P. Morgan # 8.95 0 0 22 Cindy Burke # 15.00 1 0 and another that contains this data: 5 40.0 15 42.0 16 40.0 17 41.5...

  • Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...

    Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...

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