Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Thanks so much. I updated my code as per your recommendation. It is still going on for an hour or so. Guess I will just have to wait for it to finish, but I'm sure it's better than my method.
@MathiasEttingerI tried that earlier. But the generate_combination_of_questions(IncorrectQuestions) is the part that hogs up the RAM, and I think understandably so, because it is working on the entire dataframe with all the memberid values. Because of this reason itself, I moved to the code I had pasted.
Here's what I finally wrote: for memberid in IncorrectQuestions['memberid'].unique(): for pair in generate_combination_of_questions(IncorrectQuestions[IncorrectQuestions['memberid']==memberid]): writer.writerow(pair)