0

Python 去重问题

 1 year ago
source link: https://www.v2ex.com/t/860794
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Python

Python 去重问题

  QGabriel · 3 小时 42 分钟前 · 458 次点击

list1 = [{b: 1, c: 2}, {b: 2, c: 3}, {b: 3, c: 4},{b: 2, c: 1}]
list2 = [{a: 1, d: 0.1},{a: 2, d: 0.1},{a: 3, d: 0.2},{a: 4, d: 0.3},{a: 5, d: 0.1},{a: 6, d: 0.1}]

list1 和 list2 都是 DataFrame.

问题 1: list1 怎么把{b: 2, c: 1}这种数据范围重复的值去掉?
问题 2: 把 list2 中符合(a>=b and a <= b)的 d 字段 value 相加赋值给 list1[0]['d']


各位大佬帮忙解答一下或提供思路 谢谢了


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK