简体   繁体   English

如何分别循环每一行?

[英]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.我有开始月份和结束月份,并且希望在两个月之间的每个月 output,但也包括每一行。

My desired output would be:我想要的 output 是:

[[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.抱歉造成混淆,我是 python 的新手。

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

df is the Pandas DataFrame of your table. df是您表的 Pandas DataFrame。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM