Python 将函数应用于行中元素的组合,条件是该行中不同行的值的组合
假设我有以下命令:Python 将函数应用于行中元素的组合,条件是该行中不同行的值的组合,python,pandas,itertools,Python,Pandas,Itertools,假设我有以下命令: comb = ((x, y, (256 - (x - y))/100) for x, y in combinations(df['hh'], 2) if x != y) series = Series(list(g) for k, g in groupby(comb, key=itemgetter(0))) 我还有一行名为df['name'],我想得到的是: series = ((x, y, (256 - (x - y))/100) for x, y in combinat
comb = ((x, y, (256 - (x - y))/100) for x, y in combinations(df['hh'], 2) if x != y)
series = Series(list(g) for k, g in groupby(comb, key=itemgetter(0)))
我还有一行名为df['name'],我想得到的是:
series = ((x, y, (256 - (x - y))/100) for x, y in combinations(df['hh'], 2) if df['name'].x.split('_')[0] != df['name'].y.split('_')[0])
我怎么能做到
编辑:
我的数据框架类似于
name hh
A_10 12
A_11 10
B_10 7
B_11 6
B_12 5
C_09 14
你能在该输入中包含预期结果吗?你能在该输入中包含预期结果吗?