| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
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.
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 |