[英]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.