Two Lists, Sorted Apart
Problem
An auction tool keeps a DataFrame `auction_book` (loaded from a CSV) with columns `(low_bid, high_bid)`. There is no key and the table may contain duplicate values.
Produce a two-column result that sorts each column independently and lines them up row by row:
1. `low_bid` sorted ascending.
2. `high_bid` sorted descending.
3. The two sorted sequences placed side by side (smallest `low_bid` beside largest `high_bid`, and so on).
The columns are sorted separately, so values that shared a source row are not kept together.
Input data
Example rows — the live problem includes the full dataset.
| low_bid | high_bid |
|---|---|
| 40 | 20 |
| 20 | 30 |
| 30 | 10 |
| 10 | 40 |
Expected output
Your answer should return 4 rows with the columns low_bid, high_bid.
Starter code (Pandas (Python))
import pandas as pd
def two_lists_sorted_apart(auction_book) -> pd.DataFrame:
# Your code here
return auction_bookSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock