First time here? Checkout the FAQ!
x
+1 vote
1k views
asked in Python Interview Questions by (1.4k points)  

Consider the Pandas DataDrame df below. Filter it appropriately so that it outputs the shown results.

     gh owner language      repo  stars
0  pandas-dev   python    pandas  17800
1   tidyverse        R     dplyr   2800
2   tidyverse        R   ggplot2   3500
3      has2k1   python  plotnine   1450

Expected Output

     gh owner language    repo  stars
0  pandas-dev   python  pandas  17800
  
commented by (150 points)  
Since it's the first row you can also do df.head(1).

1 Answer

+1 vote
answered by (1.4k points)  
selected by
 
Best answer
df[(df["language"]=="python") & (df["stars"]>5000)]
...