如何根据另一个数据框中值的条件填充数据框?

时间:2019-04-11 09:17:49

标签: python pandas

我有两个数据框:

  • <div *ngIf="myService.myCoupons.length"> <ul *ngFor="let c of myService.myCoupons"> <li>{{c.title}}</li> </ul> </div>``
df_new
  • time_start 0 1313575263 1 1313575263 2 1313575263 3 1313579775 4 1313579775
df_information

我想使用 my_start value 0 1313575263 foo 1 1313579775 bar 中的值来填充df_information中的新列。如果df_new中的my_startdf_information中的time_start相匹配,则使用df_new中的相应value来填充df_information。这是我想要的输出:

df_new

我想出了一种使用两个嵌套循环执行此操作的方法,但是由于我实际上是在处理大型数据帧,因此需要大量时间来运行:

 time_start value 
 0  1313575263   foo 
 1  1313575263   foo 
 2  1313575263   foo 
 3  1313579775   bar 
 4  1313579775   bar

有没有更有效的方法? 预先感谢您的帮助!

0 个答案:

没有答案