I have a pandas dataframe where 5 matching strings, lets call them "xyz" occurs x lines after a initial matching string, lets call them "intial string1" and "intial string2"
index col0 col3
500 data " initial string1"
.. .. ..
600 data "xyz"
... ... ...
1343 data "intial string1"
.. .. ..
1443 data "xyz"
... ... ...
2432 data "intial string2"
.. .. ..
2453 data "xyz"
.. .. ..
2467 data "intial string2"
.. .. ..
2487 data "xyz"
I want to be able to iterate through the dataframe starting at these indices, to find the first occurrence of "xyz" and write the rows where these "xyz" occurs to a new dataframe, and then to excel, based on which initial string it has encountered. IE store all xyz corresponding to intial string1 in a dataframe, and store all xyz corresponding to intial string2 in a another dataframe.
I am not sure how to use the combinations of iterrorws, and df["column"].str.match ("matching string") to carry out these iterations. Appreciate the help!
