Skip to content
Advertisement

Loop does not iterate over all data

I have code that produces the following df as output:

JavaScript

I built a for loop to iterate over all the elements in the ‘keyword’ column and put them separately into a new df called df1. The loop look like this:

JavaScript

The output it produces is:

JavaScript

Although the for loop works fine, it does not iterate over all the rows from df and stops more or less in the middle (it doesn’t stop always at the same spot).

Do you have an idea why? Thanks in advance

Advertisement

Answer

I dont think your for iterates all the rows.
do this: for i in range(len(df)):
Also you can remove i = i + 1

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