代写Assignment #4 - Pandas Basics代做Python编程

Assignment #4 - Pandas Basics

Goals

· importing data with pandas

· cleaning / preparing data with pandas · using pandas for basic data analysis

o   displaying summary statistics o   value counts

· consuming data from the web · merging / joining data

Overview

This homework consists of two parts:

1. Analyzing NYC Traffic Accidents data from Janurary-August 2020

2. A data cleaning / transformation project of your choice with pandas

Part 1 - NYC Trazc Accidents from Janurary-August 2020


ASCII art source(https://www.asciiart.eu/vehicles/cars)

Prep

· Download a csv of Traffic Accidents data from NYC from(./hw03/NYC_Accidents_2020.csv) from January-August 2020. note - this 2020 data was sourced from kaggle(https://www.kaggle.com/code/pabsantos/nyc-2020-accidents-

eda/data), which in turn was a snapshot of NYC Open Data's Motor Vehicle Collisions dataset (https://data.cityofnewyork.us/Public-Safety/Motor-Vehicle-Collisions-Crashes/h9gi-nx95)

o   Each record represents an individual collision, including the date, time and location of the accident (borough, zip code, street name, latitude/longitude), vehicles and victims involved, and contributing factors.

o   save the  csv file into your  data/raw directory in your repository

Starting a Notebook and General Requirements

· open up the empty notebook,  src/traffic_accidents.ipynb , in jupyterlab / jupyter notebook · go through the instructions below … and make sure that …

· ⚠ for each numbered instruction, insert a markdown cell before your code that has the first line of the instruction  ⚠ (the number and the accompanying line of text)

(no need to include the details / bulleted list underneath single instruction)

Instructions

1. import  NYC_Accidents_2020.csv as a  DataFrame.

bring in the csv file by using  read_csv from pandas; don't use any keyword arguments initially

use a relative path as if your notebook were opened from the root of the repository if possible ( ../data/raw/NYC_Accidents_2020.csv )

o   compare the resulting  DataFrame. against opening the spreadsheet in LibreOffice, Google Sheets, Excel, Numbers, etc. o   you should immediately see an issue with the import

use a keyword argument from the docs (https://pandas.pydata.org/pandas- docs/stable/reference/api/pandas.read_csv.html) to fix the issue

in a markdown cell after the import, describe what fix had to be made to make the initial import usable

2. display columns and row samples

o   show only the names of the columns o   show the first 5 rows

o   show a random sampling of 5 rows o   show the last 5 rows

3. describe the rows and data types o   use any method to show:

each column

the type of each column

the number of non-missing values in each column

in a markdown cell after displaying the column info:

list out the columns that look like they have the "wrong" (or too wide) type

and next to the column name, specify what type the column should probably be

lastly, preview the remainder of the instructions and write out any data transformations or cleaning that you think will be necessary to complete this part of the homework

4. initial column (or row) clean-up     o   remove at least two columns

in a markdown cell describe why the columns should be removed

show evidence (with code) of why each column should be removed o   rename or transform. at least one column

in a markdown cell describe why the column(s) should be renamed

o   (optional) do any other clean up you deem necessary to make the following work easier   5. determine the top three streets(Use the  ON STREET NAME column) that had the most accidents

o   it's ok to show more than 3 streets

o   show the street name and the number of accidents occurred on each street

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed 6. shows the number of accidents that occurred at each borough

o    ⚠ show a visualization that allows comparison of the number of the accidents. BRONX

BROOKLYN QUEENS

MANHATTAN

everything else can fall under "other" (including missing values)

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed

7. calculate summary statistics for the number of persons injured in all NYC and for a couple of selected boroughs (you can choose the two boroughs)

o   use any method to calculate mean, median, percentiles (25 and 75), max, and min o   again, pick two boroughs

calculate summary statistics for each borough: use any method to calculate mean, median, percentiles (25 and 75), max, and min

n    ⚠ in a markdown cell below the calculations, compare the results

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed 8. what are the distributions of accidents based on the geo location (latitude & longitude)?

o    ⚠ show a visualization that shows the accidents that occurred at each borough.

o    ⚠ that is plot the accidents based on the geo location, where x-axis is the latitude & y-axis is the longitude. And then differentiate the points by borough(by point color).

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed 9. shows the covariance between each pair of the columns

o    ⚠ choose the columns that you think are necessary & explain your choices

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed 10. which month did the most number of accidents occur?

o    ⚠ document every step that you use to do this, including how the data was cleaned and/or transformed

the calendar module and  month_abbr (https://docs.python.org/3/library/calendar.html#calendar.month_abbr) may be useful for labels

o   it's ok to show more than one month

o   optionally, visualize this data instead of simply listing the counts

o   in a markdown cell, what can you conclude about when accidents reach a lull?

Part 2 - Freeform. Pandas Project



Using your data set from the previous homework, practice using .

1. don't use the dog bites data set referenced in the course materials

2. try to write code that's different from the programs that we've done in class (it's not adequate to simply use class sample code with a different data set )

1. Reference previous assignment or write some documentation

1. Open up the empty notebook,  project.ipynb , in jupyterlab / jupyter notebook

2. In a markdown cell, either:

1. write a note mentioning that your data set was documented in the previous assignment

2. if you decide to use a different data set, describe the data that you've selected using the template markdown below:

## About the Data 1. Name / Title: (TODO name of data set) 2. Link to Data: (TODO link to any documentation about the data that you've found ) 3. Source / Origin: * Author or Creator: TODO * Publication Date: TODO * Publisher: TODO * Version or Data Accessed: TODO 4. License: (TODO name of license) 5. Can You Use this Data Set for Your Intended Use Case? (TODO answer this question) ## Format and Samples ### Overview Format: (TODO add what file format the data is in) Size: (TODO how large is the file in KB, MB, GB, etc. ... use finder, windows explorer for this) Number of Records: (TODO how many rows) ### Sample of Data TODO show a few lines of data from the actual file. ⚠️ Use "regular" Python to do this in this code block. Assuming that jupyter-lab was started in your root directory: with open('../data/raw/example-data.csv', 'r') ### Fields or Column Headers * Field/Column 1: (TODO add field name and potential type using Python types) * Field/Column 2: (TODO same as above) * Field/Column N: (TODO same as above)

2. Retrieve the data, create a DataFrame. Include the data for the graders by either:

1. downloading it and placing it into your  data/raw directory

2. linking to it in a markdown cell

Create a data frame. from the data; use any method to do this (for example   read_csv )

3. Using the Data

In a markdown cell, describe what you'd like to use the data for:

· repeat the same analysis that you did previously in plain python, but with  pandas instead · perhaps you would simply like to clean it up for further analysis later

Write code to achieve what you've written out above. The code should contain at least 4 (repetition is allowed) of the following (these can overlap with your analysis above):

· 1 filling in missing values · 1 type conversion

· 1 transform. a column

· 1 create a new calculated column · 1 visualization

· 1 calculate summary statistics · 1 calculate value counts

In a markdown cell above your code, write out which of the above requirements you're implementing. As you write your code, document your process in an accompanying markdown cell.



热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图