简体   繁体   English

如何将一个 df 中的一列除以 pandas 中不同 df 中的另一列?

[英]How do I divide one column in one df by another column in a different df in pandas?

Here's my这是我的例子

If I have two dataframes (say df4avg and df5avg) with identical corrected wavelengths and different count rates, and I want to divide the df4avg count rate by df5avg's count rate and get an output of the corrected wavelength and the new divided value with a new column name (say 'ratio'), how would I do this?如果我有两个具有相同校正波长和不同计数率的数据帧(例如 df4avg 和 df5avg),并且我想将 df4avg 计数率除以 df5avg 的计数率并得到校正波长的 output 和带有新列的新除值名称(说“比率”),我该怎么做?

If you want to add the ratio column in the df4avg Dataframe then如果要在df4avg Dataframe 中添加ratio列,则

df4avg['ratio'] = df4avg['COUNT_RATE'] / df5avg['COUNT_RATE']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中将一个df中的每一列划分为另一个df中的每一列 - Divide every column in one df to every column in another df in Python 如何将一个df的列条目匹配到另一个df; 如果它们相同,则将另一列的条目从第一个df附加到第二个df? - How do I match a column entry from one df to a different df; and if they're the same, append another column's entry from the first df to the 2nd df? 如何使用另一列中的一个键将pandas df与多列合并? - How do I merge pandas df with multiple columns using one key from another column? 如何在python / pandas中将一个df列中的字符串添加到另一个? - How do I add a piece of string from one df column to another in python/pandas? Pandas:检查一个df中的值是否存在于另一个DF的任何列中 - Pandas: Check if value in one df exists in any column of another DF 如何通过 pandas 将特定列从一个 df 复制/粘贴到另一个 - How to copy/paste particular column from one df to another by pandas 如何使用for循环在pandas df中一个接一个地添加列 - How to add column one after another in pandas df using for loop pandas df 迭代一个 df 列 qty 并以 fifo 为基础从另一个 df 列分配 qty - pandas df iterate over one df column qty and allocate qty from another df column with fifo basis 如何一次性通过DF中的熊猫行进行多列转换 - How to do multiple column conversions on a Pandas Row in a DF in one pass 如何将列名从一个 df 索引到另一个 df 系列? - How to index column names from one df to another df series?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM