Skip to content

Practice Method Chaining

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2891
LeetCode Problem

Method Chaining

Problem Statement

The animals DataFrame has name (object), species (object), age (int) and weight (int) columns. Return only names of animals with weight strictly greater than 100, ordered by decreasing weight. Complete the filtering, sorting and selection in one line using Pandas method chaining.

Source: Method Chaining on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
DataFrame animals: +----------+---------+-----+--------+ | name     | species | age | weight | +----------+---------+-----+--------+ | Tatiana  | Snake   | 98  | 464    | | Khaled   | Giraffe | 50  | 41     | | Alex     | Leopard | 6   | 328    | | Jonathan | Monkey  | 45  | 463    | | Stefan   | Bear    | 100 | 50     | | Tommy    | Panda   | 26  | 349    | +----------+---------+-----+--------+
Output
+----------+ | name     | +----------+ | Tatiana  | | Jonathan | | Tommy    | | Alex     | +----------+

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.