Question

Python help. Any help is appreciated, thank you!

Write a program that asks the user for a CSV of collision data (see note below about obtaining reported collisions from NYC OpenData). Your program should then list the top three contributing factors for the primary vehicle of collisions "CONTRIBUTING FACTOR VEHICLE 1"in the file.

A sample run: Enter CSV file name: collisionsNewYears2016.csv Top three contributing factors for collisions: Driver Inattenti

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

The chosen date is 01/01/2016 and the data can be prepared and exported according to the birthday date.

https://data.cityofnewyork.us/Public-Safety/NYPD-Motor-Vehicle-Collisions/h9gi-nx95/data

From the website, use the "Filter" option to select the birthday date and "Export" option is used to save the data on the selected date as CSV file.

Make sure the downloaded CSV file is in the same folder as that of the Python file.

PROGRAM

pd 1 import pandas 2 fileName as input (Enter CSV file name: pd.read_csv(fileName) ) 3 file 4 print (Top three contributin

import pandas as pd #Library for data manipulation and analysis
fileName = input("Enter CSV file name: ") #Takes CSV file name from user
file = pd.read_csv(fileName) #Reads the given CSV file
print("Top three contributing factors for collisions: ")
top3 = file['CONTRIBUTING FACTOR VEHICLE 1'].value_counts().nlargest(3)

#Selects the required column and list the top three according to count
print(top3)

OUTPUT

Enter CSV file name: NYPD Motor Vehicle Collisions.csv Top three contributing factors for collisions: Unspecified Driver Inat

Add a comment
Know the answer?
Add Answer to:
Python help. Any help is appreciated, thank you! Write a program that asks the user for...
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
  • Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...

    Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions. The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this...

  • ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will...

    ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...

  • 1 Overview For this assignment you are required to write a Java program that plays (n,...

    1 Overview For this assignment you are required to write a Java program that plays (n, k)-tic-tac-toe; (n, k)-tic- tac-toe is played on a board of size n x n and to win the game a player needs to put k symbols on adjacent positions of the same row, column, or diagonal. The program will play against a human opponent. You will be given code for displaying the gameboard on the screen. 2 The Algorithm for Playing (n, k)-Tic-Tac-Toe The...

  • %%%%% c++ assignment %%%%%% ///////// please test your program and check for errors. //////// you should...

    %%%%% c++ assignment %%%%%% ///////// please test your program and check for errors. //////// you should use the file bellow For this assignment you will write a program that creates a tree of "plants". Each plant is the result of an exeperiment. I have provided the main driver program that is responsible for running each of the experiments but you will need to create a tree for storing the results. The objective of this assignment is to learn how to...

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