4
私は、列がGold
とGold.1
のDataFrameを持っています。私はこれらの2つの列の違いが最大である行を探したい。以下のデータフレームのために2つの列の間に最大の差を持つ行を見つけよう
、これは私が6
df
Out:
Gold Gold.1
0 2 1
1 1 4
2 6 9
3 4 4
4 4 8
5 5 5
6 5 2 ---> The difference is maximum (3)
7 5 9
8 5 3
9 5 6
を行返す必要があります私は、次を使用してみました:
df.where(max(df['Gold']-df['Gold.1']))
ただしとValueErrorを提起している:どのように
df.where(max(df['Gold']-df['Gold.1'])) Traceback (most recent call last): File "", line 1, in df.where(max(df['Gold']-df['Gold.1'])) File "../python3.5/site-packages/pandas/core/generic.py", line 5195, in where raise_on_error) File "../python3.5/site-packages/pandas/core/generic.py", line 4936, in _where raise ValueError('Array conditional must be same shape as ' ValueError: Array conditional must be same shape as self
この条件を満たす行を見つけることはできますか?