<i id='Gy5If'><tr id='Gy5If'><dt id='Gy5If'><q id='Gy5If'><span id='Gy5If'><b id='Gy5If'><form id='Gy5If'><ins id='Gy5If'></ins><ul id='Gy5If'></ul><sub id='Gy5If'></sub></form><legend id='Gy5If'></legend><bdo id='Gy5If'><pre id='Gy5If'><center id='Gy5If'></center></pre></bdo></b><th id='Gy5If'></th></span></q></dt></tr></i><div id='Gy5If'><tfoot id='Gy5If'></tfoot><dl id='Gy5If'><fieldset id='Gy5If'></fieldset></dl></div>
      <bdo id='Gy5If'></bdo><ul id='Gy5If'></ul>

  • <tfoot id='Gy5If'></tfoot>

      1. <small id='Gy5If'></small><noframes id='Gy5If'>

      2. <legend id='Gy5If'><style id='Gy5If'><dir id='Gy5If'><q id='Gy5If'></q></dir></style></legend>

        根据 pandas 中的另一个列值有条件地填充列值

        时间:2024-04-21

            <tfoot id='rzboU'></tfoot>
            <legend id='rzboU'><style id='rzboU'><dir id='rzboU'><q id='rzboU'></q></dir></style></legend>
            • <bdo id='rzboU'></bdo><ul id='rzboU'></ul>
            • <i id='rzboU'><tr id='rzboU'><dt id='rzboU'><q id='rzboU'><span id='rzboU'><b id='rzboU'><form id='rzboU'><ins id='rzboU'></ins><ul id='rzboU'></ul><sub id='rzboU'></sub></form><legend id='rzboU'></legend><bdo id='rzboU'><pre id='rzboU'><center id='rzboU'></center></pre></bdo></b><th id='rzboU'></th></span></q></dt></tr></i><div id='rzboU'><tfoot id='rzboU'></tfoot><dl id='rzboU'><fieldset id='rzboU'></fieldset></dl></div>
            • <small id='rzboU'></small><noframes id='rzboU'>

                    <tbody id='rzboU'></tbody>
                  本文介绍了根据 pandas 中的另一个列值有条件地填充列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含几列的 DataFrame.一列包含使用货币的符号,例如欧元或美元符号.另一列包含预算值.因此,例如,在一行中,它可能意味着 5000 欧元的预算,而在下一行中,它可能意味着 2000 美元的预算.

                  I have a DataFrame with a few columns. One columns contains a symbol for which currency is being used, for instance a euro or a dollar sign. Another column contains a budget value. So for instance in one row it could mean a budget of 5000 in euro and in the next row it could say a budget of 2000 in dollar.

                  在 pandas 中,我想在我的 DataFrame 中添加一个额外的列,以欧元规范化预算.所以基本上,对于每一行,新列中的值应该是预算列中的值 * 1 如果货币列中的符号是欧元符号,新列中的值应该是预算列的值 *如果货币列中的符号是美元符号,则为 0.78125.

                  In pandas I would like to add an extra column to my DataFrame, normalizing the budgets in euro. So basically, for each row the value in the new column should be the value from the budget column * 1 if the symbol in the currency column is a euro sign, and the value in the new column should be the value of the budget column * 0.78125 if the symbol in the currency column is a dollar sign.

                  我知道如何添加一列、用值填充它、从另一列复制值等,但不知道如何根据另一列的值有条件地填充新列.

                  I know how to add a column, fill it with values, copy values from another column etc. but not how to fill the new column conditionally based on the value of another column.

                  有什么建议吗?

                  推荐答案

                  你可能想做

                  df['Normalized'] = np.where(df['Currency'] == '$', df['Budget'] * 0.78125, df['Budget'])
                  

                  这篇关于根据 pandas 中的另一个列值有条件地填充列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:except: 和 except Exception as e 之间的区别: 下一篇:Python,带有基本身份验证的 HTTPS GET

                  相关文章

                  <tfoot id='FoFpy'></tfoot>
                    • <bdo id='FoFpy'></bdo><ul id='FoFpy'></ul>
                  1. <small id='FoFpy'></small><noframes id='FoFpy'>

                      <i id='FoFpy'><tr id='FoFpy'><dt id='FoFpy'><q id='FoFpy'><span id='FoFpy'><b id='FoFpy'><form id='FoFpy'><ins id='FoFpy'></ins><ul id='FoFpy'></ul><sub id='FoFpy'></sub></form><legend id='FoFpy'></legend><bdo id='FoFpy'><pre id='FoFpy'><center id='FoFpy'></center></pre></bdo></b><th id='FoFpy'></th></span></q></dt></tr></i><div id='FoFpy'><tfoot id='FoFpy'></tfoot><dl id='FoFpy'><fieldset id='FoFpy'></fieldset></dl></div>
                      <legend id='FoFpy'><style id='FoFpy'><dir id='FoFpy'><q id='FoFpy'></q></dir></style></legend>