简体   繁体   English

比较两个不同的熊猫数据框中的两列值

[英]compare two columns values in two different pandas data frames

I have two data sets;我有两个数据集; set A has the full values with columns' names ('Temp', 'Humidity', 'Label' ) and set B has predictions for the Label value for some of the readings of the full list ('Temp', 'Humidity', 'Predicted Label').集合 A 具有带有列名称的完整值 ('Temp', 'Humidity', 'Label' ),集合 B 具有对完整列表中某些读数的 Label 值的预测 ('Temp', 'Humidity', '预测标签')。 I want to compare the Label value of the same readings in both full lists and the predictions to calculate the error.我想比较完整列表和预测中相同读数的标签值以计算误差。 How can I do that using pandas?我怎样才能使用熊猫做到这一点?

you can merge your two Dataframes.您可以合并您的两个数据框。 What do you mean by comparing?比较是什么意思? Are those numbers?是那些数字? If so you can do this :如果是这样,你可以这样做:

Comparison_Dataframe = A.merge(B, on=['Temp', 'Humidity'], how='inner')
Comparison_Dataframe['result'] = Comparison_Dataframe['Label'== 'Predicted Label']

The second line would add a boolean equality column.第二行将添加一个布尔相等列。

如果错误是指差异,并且两个数据帧的顺序相同:

df = A - B

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

相关问题 如何比较两个不同数据帧的列并保持公共值 - How to compare columns of two different data frames and keep the common values 如何比较不同数据框中的两列并替换值 - how to compare two columns in different data frames & replace the values 如何比较两个不同数据框中的两列并计算出现次数 - how to compare two columns in two different data frames and count the occurrences 组合来自两个不同数据帧的两列以删除 Pandas 中的缺失值 - Combing two columns from two different data frames to remove missing values in Pandas 基于具有相同值对但在两个数据框中以不同顺序显示的两列合并熊猫数据框 - Merge pandas data frames based on two columns with the same pair of values but displayed in different orders in the two dataframes 使用 pandas 比较两个数据帧的多列 - Compare multiple columns of two data frames using pandas 如何比较两个不同数据框中的列并保留第一个数据框中的值? - How to compare columns from two different Data Frames and keep the values from the first Data Frame? 比较两个熊猫数据帧中的值,与顺序无关 - Compare values from two pandas data frames, order-independent 如何比较python中两个不同数据框的列? - how to compare columns of two different data frames in python? 如何比较具有相同列但行数不同的两个数据帧? - How to compare two data frames with same columns but different number of rows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM