g2801_2900.s2891_method_chaining.solution.py Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java21 Show documentation
Show all versions of leetcode-in-java21 Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
# #Easy #2023_12_25_Time_412_ms_(99.23%)_Space_60.8_MB_(50.69%)
import pandas as pd
def findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame:
animal_data = {}
for index in animals.index:
animal = animals.iloc[index]
if animal['weight'] > 100:
animal_data[animal['name']] = animal['weight']
animal_data = dict(sorted(animal_data.items() , key = lambda x : x[1] , reverse = True))
result = pd.DataFrame(animal_data.keys() , columns = ['name'])
return result