AnalystPath

Quietly Rented Board Games

PandasMediumMid level~10 min

Problem

A board game cafe lends out games and tracks every rental.

DataFrame: `game` (`game.csv`)

```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| game_id | int |
| title | object |
| shelved_on | object |
+-------------+--------+
```
`game_id` is unique. `shelved_on` is the date the game first became available to rent.

DataFrame: `rental` (`rental.csv`)

```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| rental_id | int |
| game_id | int |
| copies | int |
| rented_on | object |
+-------------+--------+
```
`rental_id` is unique. Each row records that some copies of a game were rented on a date.

Write a function that returns the games rented fewer than 10 copies in the last year, excluding any game on the shelf for less than one month. Assume today is 2023-06-23, so 'last year' means rentals on or after 2022-06-23, and a game is too new if it was shelved on or after 2023-05-23. Return columns `game_id` and `title` in any order.

Input data

Example rows — the live problem includes the full dataset.

game
game_idtitleshelved_on
1Catacomb Quest2014-01-01
2River Trade2016-05-12
3Skyline Rails2023-06-10
4Meadow Keepers2023-06-01
5Tidepool2008-09-21
rental
rental_idgame_idcopiesrented_on
1122022-07-26
2112022-11-05
3382023-06-11
4462023-06-05
5452023-06-20

Expected output

Your answer should return 3 rows with the columns game_id, title.

Starter code (Pandas (Python))

import pandas as pd

def quiet_games(game: pd.DataFrame, rental: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return game

Solve 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

Related Pandas questions