CommencerCommencer gratuitement

Did you say dystopia?

Another day at work, another day working with your book project! You are very excited because you have been making a lot of progress. You plan to work on a dataset about dystopian fiction books.

But first, you need to do some string manipulations. You realize that the DataFrame index contains data about the title and the release year. You can't find a column with the author of the book, so you decide to pre-define a list of the writers. Then, you want to delete the year and replace it with the author.

You decide that splitting the index and then concatenating it with the list is the best way to do it.

The books_dys dataset and author_list are available for you. Make sure to examine it in the console!

Cet exercice fait partie du cours

Reshaping Data with pandas

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Split the index of books_dys by the hyphen 
books_dys.index = books_dys.____.____.____(____)

# Print books_dys
print(books_dys)
Modifier et exécuter le code