FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Intro_to_Data_Science/Project_1 at master · abeldavid/Intro_to_Data_Science · GitHub

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Project_1: How to import a csv file into python using PANDAS and do simple imputations using fillna(value).

Data Set :

The dataset (csv-file format) we are using can be downloaded from http://www.seanlahman.com/baseball-archive/statistics containing details of baseball players.

Add the path to the Lahman baseball csv that points to the Master.csv file and a path for the new csv.

Objective:

Assume you will be reading in a csv file with the same columns that the #Lahman baseball data set has -- most importantly, there are columns #called 'nameFirst' and 'nameLast'. #1) Write a function that reads a csv #located at "path_to_csv" into a pandas dataframe and adds a new column #called 'nameFull' with a player's full name. # #For example: # for Hank Aaron, nameFull would be 'Hank Aaron', # #2) Write the data in the pandas dataFrame to a new csv file located at #path_to_new_csv #3) Pandas dataframes have a method called 'fillna(value)', such that you can # pass in a single value to replace any NAs in a dataframe or series. You # can call it like this: # dataframe['column'] = dataframe['column'].fillna(value) # # Using the numpy.mean function, which calculates the mean of a numpy # array, impute any missing values in our Lahman baseball # data sets 'weight' column by setting them equal to the average weight. # # You can access the 'weight' colum in the baseball data frame by # calling baseball['weight']


Back | FazBrowse Home | New Git URL