Skip to content

Commit b215e71

Browse files
authored
Better solution
1 parent 17c6bc9 commit b215e71

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

introduction_pandas/2891_method_chaining.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
import pandas as pd
5555

5656
def findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame:
57-
filtered_animals = animals[animals['weight'] > 100].sort_values('weight', ascending = False)
58-
return filtered_animals[['name']]
57+
sorted_animals = animals.sort_values("weight", ascending = False)
58+
return sorted_animals[sorted_animals['weight']>100][['name']]

0 commit comments

Comments
 (0)