Book Availability Update
Start Timer
0:00:00
As a Python-proficient librarian, you’re building a system to check the availability of book copies more efficiently.
Write a function update_availability
to update the copies_available
value for a specific book_id
in your dataframe and return the updated dataframe.
Note: If you can’t find the book_id
, return the original dataframe without any changes.
Example:
Input:
input_df
book_id | book_title | copies_available |
---|---|---|
0 | Moby Dick | 5 |
1 | 1984 | 7 |
2 | To Kill a Mockingbird | 3 |
3 | The Great Gatsby | 2 |
4 | Pride and Prejudice | 10 |
Output:
update_availability(book_id=3, copies=8, df_books=input_df) ->
book_id | book_title | copies_available |
---|---|---|
0 | Moby Dick | 5 |
1 | 1984 | 7 |
2 | To Kill a Mockingbird | 3 |
3 | The Great Gatsby | 8 |
4 | Pride and Prejudice | 10 |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments