23.4 Project 4: Using Pandas for data analysis and practice with error handling
Python Please!
Let me know if you need any other modifications import pandas as pd import os def displayMenu(): print("(1) Get max mpg model") print("(2) Get min mpg model") print("(3) Get model year range") print("(4) Exit") def get_max_mpg_model(carsdataframe, country): # convert the country name to lowercase. # just for indexing purpose that usa, USA, UsA all index the same. country = country.lower() # get a subset of the dataframe containing mpg and name for given country tempData = carsData[carsData['origin']==country][['mpg','name']] if tempData.empty: return "Invalid country" # return name at first Max mpag return "Best mpg model from {} is {}".format(country,tempData.loc[tempData['mpg'].idxmax(())]['name']) def get_min_mpg_model(carsdataframe, country): # convert the country name to lowercase. # just for indexing purpose that usa, USA, UsA all index the same. country = country.lower() # get a subset of the dataframe containing mpg and name for given country tempData = carsData[carsData['origin']==country][['mpg','name']] if tempData.empty: return "Invalid country" # return name at first Max mpag return "Worst mpg model from {} is {}".format(country,tempData.loc[tempData['mpg'].idxmin(())]['name']) def get_model_year_range(carsdataframe, country): # convert the country name to lowercase. # just for indexing purpose that usa, USA, UsA all index the same. country = country.lower() # get a subset of the dataframe containing only the years for given country tempData = carsData[carsData['origin']==country][['model_year']] if tempData.empty: return "Invalid country" # return min year and max year return "Model years range from 19{} to 19{}".format( tempData.loc[tempData['model_year'].idxmin(())]['model_year'],\ tempData.loc[tempData['model_year'].idxmax(())]['model_year']) if __name__ == "__main__": fileName = input("Enter the filename: ") # check if file exists if os.path.exists(fileName): # create a dataframe using CSV carsData = pd.read_csv(fileName) while(True): displayMenu() try: menuOption = int(input("Enter selection 1-4: ")) if menuOption in range(1,4): country = input("Enter the country of origin: ") if menuOption == 1: print(country, get_max_mpg_model(carsData, country)) elif menuOption == 2: print(country, get_min_mpg_model(carsData, country)) elif menuOption == 3: print(get_model_year_range(carsData, country)) elif menuOption == 4: exit(0) else: print("Invalid selection - must be a number from 1 to 4") except ValueError: print("Invalid selection - must be a number from 1 to 4") else: print("Can't open fie. Exiting program.")
input data
23.4 Project 4: Using Pandas for data analysis and practice with error handling Python Please! 23.4...
23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same as what you had for your chapter 13 labs). The following is an example of...
22.39 LAB 13 C FALL 2019 Overview Demonstrate your ability to use pandas with functions Description Write a program that reads data from an input file using a DataFrame and displays a subset of data using a method Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format: mpg, cylinders, displacement, horsepower, weight, acceleration, model_year, origin, name 18,9,307,130,3504, 12, 70, usa, chevrolet chevelle malibu 15,8,350,165,3693, 11.5,70, usa, buick skylark...
Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...
Hi - Some help create a short program that uses a pandas DataFrame (solution MUST use a DataFrame) to do the following. Please include comments /notes to explain what is going on. Solution does not need to define functions two csv files are included (grades01.csv): raw marks of students taking an examination; and a further csv file (rubric01.csv) summarizing the maximum mark available for each of the six questions. Structure of grades01: Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6...
In this project, you will use functions and dictionaries to track basketball players and their respective points, then display statistics of points made. You will need three functions as follows: def freeThrowMade(playerDictionary, playerName) - this function will add 1 point to the player's total score def twoPointMade(playerDictionary, playerName) - this function will add 2 points to the player's total score def threePointMade(playerDictionary, playerName) - this function will add 3 points to the player's total score Each of these functions has...
This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...
Programming Instructions:Using Java Object Oriented Principles, write a program which produces the code as indicated in the following specifications: Your program must be a console application that provides a user this exact menu:Please select one of the following:1: Add Client to Bank2: Display Clients in the Bank3: Set Bank Name4: Search for a Client5: Exit Enter your Selection: <keyboard input here> The menu must be displayed repeatedly until 5...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
Please I need help a sample code is provided below of the output Description This project is an enhancement of your previous project using OOP concepts. You'lI define class and instantiate objects instead of using struct to implement your design Write a menu-driven program that provides the following options 1. Show All 2. Spend 3. Search expenses containing this string 4. Search expenses with greater than or equal to this amount 5. Exit It allows the user to select a...
The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...