I have an index with the following numbers (5, 10, 15, 17) This index is generated from a large csv file and corresponds to the order of these phrases from that file. Eventually id like to map these phrases back with the new columns my loop generates.
Each index is associated with a phrase. My code separates the phrase and creates columns based on words in the phrase. I need to create another column in my data frame with the index number that corresponds to each phrase.
For example:
column 1 column 2 index
phrase A book 5
phrase A tree 5
phrase B tree 10
How would I achieve this result within my loop and make sure the index is changing with every new input in column 1.