Skip to content
Advertisement

How to fill cell by cell of an empty pandas dataframe which has zero columns with a loop?

I need to scrape hundreds of pages and instead of storing the whole json of each page, I want to just store several columns from each page into a pandas dataframe. However, at the beginning when the dataframe is empty, I have a problem. I need to fill an empty dataframe without any columns or rows. So the loop below is not working correctly:

JavaScript

In this case, what should I do?

Advertisement

Answer

You can solve this by using enumerate(), together with loc:

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