Skip to content
Advertisement

adding consequently items of a list to a dataframe

As a practice, I have created the following dataset of reading books:

JavaScript

Then I added a fourth column as follows

JavaScript

And now I would like to add as follows (I mean as rows 5 and 6) the following item, always by using the list

JavaScript

I have tried adding other titles

JavaScript

the following code which does not work:

JavaScript

Since I am at the very beginning I would be very willing to explore different solutions to explore how to add as follows the further list’s names (I thought also about a for loop which I do not how to set out)

Thanks

Advertisement

Answer

Check below code. It uses numpy.vstack to add list rows to existing data frame. Using your code from above for continuity, new code starts after the commented line Adding list rows to dataframe

JavaScript

Output: enter image description here

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement