本文整理匯總了Python中rule.Rule.add_dataset方法的典型用法代碼示例。如果您正苦於以下問題:Python Rule.add_dataset方法的具體用法?Python Rule.add_dataset怎麽用?Python Rule.add_dataset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rule.Rule
的用法示例。
在下文中一共展示了Rule.add_dataset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: apply_rule
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import add_dataset [as 別名]
for condition in dataset.conditions:
if (ds_final_condition is not None):
result = self._apply_condition(condition)
ds_final_condition = result & ds_final_condition
else:
ds_final_condition = self._apply_condition(condition)
return ds_final_condition
def apply_rule(self):
for dataset in self.rule.datasets:
if (self.final_condition is None):
self.final_condition = self._get_dataset(dataset)
else:
self.final_condition = self._get_dataset(dataset) | self.final_condition
return self.dataframe[self.final_condition]
if __name__ == '__main__':
from rule import Rule,DataSet,ListCondition,ValueCondition
data = [['a',1,'10'],['b',2,20],['c',3,30]]
df = pd.DataFrame(data=data,columns=['col1','col2','col3'])
ds1 = DataSet("first")
ds1.add_condition(ValueCondition('col1','a'))
ds1.add_condition(ListCondition('col2',[1,2]))
ds2 = DataSet("second")
ds2.add_condition(ValueCondition('col1','c'))
ds2.add_condition(ValueCondition('col3',30))
rule = Rule("test rule")
rule.add_dataset(ds1)
rule.add_dataset(ds2)
fdf = FilteredDataFrame(dataframe=df,rule=rule)
print(fdf.apply_rule())