回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>熊猫的价值:</p>
<pre><code>Index Bra Obr Zal Uto Str Nah Tec Ryc Hla BestP_A BestP_Amin BestP_minA
0 461 38 44 46 49 137 324 322 162 Bra Obr 137.0
1 442 32 30 35 39 180 322 325 180 Bra Obr 180.0
2 152 28 23 23 30 175 335 355 206 Bra Obr 175.0
3 38 33 68 33 49 119 223 46 46 Zal Obr 46.0
4 36 33 203 36 46 217 253 166 170 Zal Obr 166.0
5 35 84 38 41 54 49 175 57 141 Obr Nah 49.0
6 34 45 71 45 59 72 207 57 60 Zal Obr 57.0
</code></pre>
<p><a href="https://i.stack.imgur.com/zldZr.png" rel="nofollow noreferrer">Value from Pandas</a></p>
<p>我需要返回列名到列“BestP\u Amin”,Python返回错误的列名。值索引0示例:</p>
<pre><code>BestP_A = Bra, Bra = 461, Nah = 137, Tec = 324, Ryc = 322, Hla = 162
</code></pre>
<p>代码:</p>
<pre class="lang-py prettyprint-override"><code>if data.at[i,'BestP_A'] == 'Bra':
data['BestP_Amin'] = data[['Bra','Nah','Tec','Ryc','Hla']].idxmin(axis=1)
</code></pre>
<p>返回值<code>Obr</code>,问题在哪里?
块代码:</p>
<pre><code># nalezení nejleší pozice, přepočet podle výše atributů
for i in range(0,len(data.index)):
# nalezení pozice
data['BestP_A'] = data[['Bra','Obr','Zal','Uto']].idxmax(axis=1)
#nalezení nejmenšího atributu
# VRACI CHYBNE HODNOTY
if data.at[i,'BestP_A'] == 'Bra':
data['BestP_Amin'] = data[['Bra','Nah','Tec','Ryc','Hla']].idxmin(axis=1)
elif data.at[i,'BestP_A'] == 'Obr':
data['BestP_Amin'] = data[['Obr','Nah','Tec','Ryc','Hla']].idxmin(axis=1)
elif data.at[i,'BestP_A'] == 'Zal':
data['BestP_Amin'] = data[['Zal','Nah','Tec','Ryc','Hla']].idxmin(axis=1)
elif data.at[i,'BestP_A'] == 'Uto':
data['BestP_Amin'] = data[['Uto','Nah','Tec','Ryc','Hla']].idxmin(axis=1)
data.at[i,'BestP_minA'] = min(data.at[i,'Nah'],data.at[i,'Tec'],data.at[i,'Ryc'],data.at[i,'Hla'])
data.at[i,'BestA_U'] = int(round(data.at[i,'BestA']*(data.at[i,'Ene']/100)*(1+(.25*data.at[i,'Sou']/100)+(.2*data.at[i,'Zku']/100)),0))
</code></pre>
<p><a href="https://i.stack.imgur.com/Uukpg.png" rel="nofollow noreferrer">Block code in python:</a></p>