Skip to content
C

Filter and Sort a DataFrame

Mediumpython

Given a DataFrame of employees (name, department, salary), filter to show only those earning above 50000, sorted by salary in descending order.

Approach: build the DataFrame from the given rows, filter with a boolean condition (df["salary"] > 50000), then sort_values("salary", ascending=False).

Input: First line: the number of employees n. Next n lines: name,department,salary.

Output: One line per employee earning above 50000, sorted by salary descending, each as a tuple (name, department, salary).

Input (stdin)

Output

Run your code to see output here...