【发布时间】:2019-11-03 18:41:42
【问题描述】:
我有一个这样的数据框:
df1:
start_date end_date
0 20180101 20181231
1 20170101 20171231
另一个这样的数据框:
df2:
Type Value
0 House 100
1 Car 200
2 Bus 300
3 House 150
4 Car 220
5 Bus 320
我需要将 df1 的第一个值(start_date 20180101 和 end_date 20181231)应用于第一轮 df2 类型,第二个应用于第二轮,依此类推(第一次出现“House”应该有 start_date 20180101 和 end_date 20181231;第二次“房子”出现它应该有 start_date 20170101 和 end_date 20171231 等等)。它应该是这样的:
df3:
Type Value start_date end_date
1 House 100 20180101 20181231
2 Car 200 20180101 20181231
3 Bus 300 20180101 20181231
4 House 150 20170101 20171231
5 Car 220 20170101 20171231
6 Bus 320 20170101 20171231
有什么想法吗?
【问题讨论】: