Classwork 10
Pandas Fundamental I: Loading, Summarizing, and Counting Data
Direction
The nfl.csv file (with its pathname https://bcdanl.github.io/data/nfl.csv) contains a list of players in the National Football League with similar Name, Team, Position, Birthday, and Salary variables in the nba.csv file.
Question 1
- How can we read the nfl.csv file, and assign it to a
DataFrameobject,nfl? - What is an effective way to convert the values in its
Birthdayvariable todatetimes?
Answer:
Question 2
- How many observations are in
nfl? - What are the mean, median, standard deviation, minimum, and maximum of
Salaryinnfl?
Answer:
Question 3
- What are the maximum and minimum values of
Salaryinnfl? - What is the 75th percentile of
Salaryinnfl?
Answer:
Question 4
- Create a new Series that concatenates each player’s
NameandPositionin the formatName (Position)using a vectorized string operation. - Create a new Series that shows how much each player’s
Salarydeviates from the mean salary.
Answer:
Question 5
- How can we select only the
NameandTeamvariables fromnflas aDataFrame? - How can we reorder the variables so that
Teamappears beforeName?
Answer:
Question 6
- Add a new variable
Salary_ktonflthat expressesSalaryin thousands of dollars. - Add another new variable
Salary_2xtonflthat doubles the originalSalary.
Answer:
Question 7
- Remove the variables
Salary_kandSalary_2xfromnfl.
Answer:
Question 8
- Rename the variable
BirthdaytoDate of Birthinnfl.
Answer:
Question 9
- How can we count the number of players per team in
nfl? - How many players are there per position in
nfl?
Answer:
Question 10
- How many unique teams are in
nfl? - How many unique positions are in
nfl?
Answer:
Discussion
Welcome to our Classwork 10 Discussion Board! 👋
This space is designed for you to engage with your classmates about the material covered in Classwork 10.
Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.
If you have any specific questions for Byeong-Hak (@bcdanl) regarding the Classwork 10 materials or need clarification on any points, don’t hesitate to ask here.
All comments will be stored here.
Let’s collaborate and learn from each other!