'How to loop each row separately?

I have two rows that I would like to loop for each row. I have start month and end month, and would like to output each month in between the two months but also including them for each row.

My desired output would be:

[[7,8,9,10,11,12], [7,8,9,10,11,12],[7,8,9,10,11,12], [9,10,11,12], [11,12]... etc

Any Idea on how to do so? Sorry for the confusion, I am new to python.



Solution 1:[1]

list(map(lambda x : list(range(x[0], x[1]+1)), df[['StartMonth','EndMonth']].values))

df is the Pandas DataFrame of your table.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SM1312