我最后得出的结论是:def transform(self, attribute):
try:
attribute = float(attribute)
if math.isnan(attribute):
attribute = "NULL"
print type(attribute)
return attribute
except ValueError:
attribute = str(attribute)
print type(attribute)
return attribute
def equals(self, attribute, value):
return self.transform(attribute) == self.transform(value)
def not_equals(self, attribute, value):
return self.transform(attribute) != self.transform(value)
def greater_than(self, attribute, value):
return self.transform(attribute) > self.transform(value)
def greater_than_equal(self, attribute, value):
return self.transform(attribute) >= self.transform(value)
def less_than(self, attribute, value):
return self.transform(attribute) < self.transform(value)
def less_than_equal(self, attribute, value):
return self.transform(attribute) <= self.transform(value)
因为我只需要几个操作员,所以这是我能想出的最好的解决方案。transform()只是为了处理我在特定数据集中遇到的一些比较问题。希望这能对将来的人有所帮助!如果有人有意见或建议,请告诉我。在