Iteration through rows of pandas dataframe: Breaking out educational details

Iteration through rows of pandas dataframe: Breaking out educational details

3 Березня 2024 в 18:08 31

I am facing a challenge while iterating through rows of a pandas dataframe in Python. Specifically, I am reading data from an excel sheet using pandas and then iterating through the data using df.iterrows(), processing it further to automate a work flow using python/selenium. Each row of my spreadsheet belongs to job applicants and their attributes are getting captured in different columns. However, since a person can have multiple degrees their educational details are captured in columns as degree1, specialation1, college1, degree2, specialiation2, college2, etc. Maximum 5 qualifications can be filled in. During iteration, I want to breakout and then loop through rows of education (degree, specialization, college) for one person. How to accomplish this task? I am attaching a github link of the sample data for reference text which basically has the same data as is pasted below:

python

I tried grouping it using a custom function presented below. But it does not give the desired results.

Thanks in advance for your inputs!