import pandas as pd
import numpy as np
# Below is for an interactive display of DataFrame in Colab
from google.colab import data_table
data_table.enable_dataframe_formatter()
netflix = pd.read_csv(
"https://bcdanl.github.io/data/netflix.csv"
)Classwork 12
Pandas Fundamental III: Data Types; Filtering Data By a Condition
Direction
The netflix.csv file (with its pathname https://bcdanl.github.io/data/netflix.csv) contains a list of 6,000 titles that were available to watch in November 2019 on the video streaming service Netflix. It includes four variables: the video’s title, director, the date Netflix added it (date_added), and its type (category).
Question 1
Read netflix.csv as a DataFrame named netflix.
Answer:
Question 2
Inspect the data types of all variables in netflix.
Answer:
Question 3
Convert the type variable to the category data type.
Answer:
Question 4
Convert the date_added variable to a proper datetime format.
Answer:
Question 5
Optimize the DataFrame for limited memory use and maximum utility by converting type to category and date_added to datetime.
Answer:
Question 6
Find all observations with a director of “Martin Scorsese”.
Answer:
Question 7
Find all observations whose type is not "Movie".
Answer:
Question 8
Find all observations with a title of “Limitless” and a type of “Movie”.
Answer:
Question 9
Find all observations with either a date_added of "2018-06-15" or a director of “Bong Joon Ho”.
Answer:
Question 10
Find all observations with a director of “Ethan Coen”, “Joel Coen”, or “Quentin Tarantino”.
Answer:
Question 11
Find all observations with a date_added value between January 1, 2019 and February 1, 2019.
Answer:
Question 12
Find all observations whose title begins with a letter between "S" and "T" using between().
Answer:
Question 13
Use the query() method to find all movies added on or after January 1, 2019.
Answer:
Question 14
Create a new variable named recent_addition using np.where(). Let it be "Yes" if date_added is on or after January 1, 2019, and "No" otherwise.
Answer:
Discussion
Welcome to our Classwork 12 Discussion Board! 👋
This space is designed for you to engage with your classmates about the material covered in Classwork 12.
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 12 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!