A retail platform wants to identify its highest-value customers. Return the top 5 customers by total spend in descending order, resetting the index. If fewer than 5 customers exist, return all of them.
df
| column | type |
|---|---|
| customer_id | int |
| name | str |
| total_spend | float |
| customer_id | name | total_spend |
|---|---|---|
| 1 | Alice | 500.0 |
| 2 | Bob | 1200.0 |
| 3 | Carol | 800.0 |
| 4 | Dave | 350.0 |
| 5 | Eve | 950.0 |
| 6 | Frank | 600.0 |
| 7 | Grace | 200.0 |
| customer_id | name | total_spend |
|---|---|---|
| 2 | Bob | 1200.0 |
| 5 | Eve | 950.0 |
| 3 | Carol | 800.0 |
| 6 | Frank | 600.0 |
| 1 | Alice | 500.0 |
The five highest spenders are selected in descending order; Dave (350.0) and Grace (200.0) are excluded.
df shape = (6, 3), columns: customer_id, name, total_spend