← Quiz: pandas Basics: all 10 questions
Quiz: pandas Basics · Question 8 of 10
What does this print? (code)
What does this print?
import pandas as pd
df = pd.DataFrame({"city": ["Pune", "Jaipur", "Pune", "Delhi"], "cgpa": [7.2, 8.9, 8.1, 6.5]})
print(df[df["city"].isin(["Pune", "Delhi"]) & (df["cgpa"] > 7)]["cgpa"].tolist())
- A.[7.2, 8.1]
- B.[7.2, 8.1, 6.5]
- C.[8.9]
- D.[6.5]
Answer & explanation
Correct answer: [7.2, 8.1]
Delhi's 6.5 fails the CGPA condition; Jaipur fails the city condition.
Can you get the rest right without peeking?
Take the timed Quiz: pandas Basics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →