Package: evaluate-dfs
Evaluate DataFramesevaluate_dfsprovides features for evaluating a series or dataframe against another series or dataframe.Installationpipinstallevalaute-dfsOverviewevaluate_dfscontains many features to help evaluate series or dataframe against another series or dataframe:dfs_evaluator: Classes for evaluating two dataframes against each other.series_evaluator: Classes for evaluating a series against a dataframe.match: Functions for ranking and matching the highest ranking item in an iterable according to a hierarchy.Here's a tour of some of the main features ofevaluate_dfswith examples:Series EvaluatorsThe main features of theseries_evaluatormodule are theSeriesEvaluatorclass and its subclasses.You can store yourevaluation mappinginto these classes, composed of:evaluation field name(keys), the field name to assign the results from an evaluation function to anevaluation.evaluation function(values), a function that compares two series.Example of an evaluation mapping:defevaluate_fruits(series1,series2):returnseries1.fruits==series2.fruitsdefevaluate_vegies(series1,series2):returnseries1.vegies==series2.vegiessmoothie_evaluations={'is_fruits_same':evaluate_fruits,'is_vegies_same':evaluate_vegies}Anevaluationis a series returned or produced by methods from aSeriesEvaluator(or subclass) instance. The evaluation contains the return values from comparing  two series with all theevaluation functionsfrom anevaluation mapping,
withevaluation field namesas its indexes. By default, and evaluation stores the indexes of both series compared.Example of an evaluation:index_x              0
index_y             42
is_fruits_same    True
is_vegies_same    True
dtype: objectAdditionally, the classes offer the following features:Pre-filtering the dataframe before evaluation.The field_names attribute, which dynamically stores theevaluation field namesand/or the indexes field names to use for each evaluation.Options to specify the indexes field names or ommit recording the indexes for the evaluations.Examples of using theSeriesEvaluatorclass:importpandasaspdfromevaluate_dfs.series_evaluatorimportSeriesEvaluatorapple=pd.Series(['apple'],index=['fruits'],name=0)fruit_basket=pd.DataFrame({'fruits':['apple','peach','orange']})defare_fruits_equal(series1:pd.Series,series2:pd.Series)->bool:returnseries1.fruits==series2.fruitsseries_evaluator=SeriesEvaluator(mapping={'fruits_equal':are_fruits_equal},)evaluations=series_evaluator.evaluate_against_df(series=apple,df=fruit_basket)pd.DataFrame(evaluations)index_x  index_y  fruits_equal
0        0        0          True
1        0        1         False
2        0        2         FalseWith a filter function:deffilter_out_orange(series:pd.Series,df:pd.DataFrame)->pd.DataFrame:returndf[df['fruits']!='orange']series_evaluator=SeriesEvaluator(mapping={'fruits_equal':are_fruits_equal},filter_df=filter_out_orange)evaluations=series_evaluator.evaluate_against_df(series=apple,df=fruit_basket)pd.DataFrame(evaluations)index_x  index_y  fruits_equal
0        0        0          True
1        0        1         FalseDataFrames EvaluatorsThe main features of thedfs_evaluatormodule are theDataFramesEvaluatorclass and its subclasses. They provide methods for evaluating every row (series) from one dataframe against every row, if a filter function not provided for the series evaluator instance.A dataframes evaluator instance is composed of anSeriesEvaluator(or subclass) instance found in theseries_evaluatormodule.Additionally,dfs_evaluatoralso provides theParallelEvaluatorthat works just likeSeriesEvaluator, but processes the evaluations in parallel.A quick example of using theDataFramesEvaluatorclass:importpandasaspdfromevaluate_dfs.series_evaluatorimportSeriesEvaluatorfromevaluate_dfs.dfs_evaluatorimportDataFramesEvaluatorfruit_basket1=pd.DataFrame({'fruits':['apple','pineapple']})fruit_basket2=pd.DataFrame({'fruits':['apple','peach']})defare_fruits_equal(series1:pd.Series,series2:pd.Series)->bool:returnseries1.fruits==series2.fruitsseries_evaluator=SeriesEvaluator(mapping={'fruits_equal':are_fruits_equal},)dfs_evaluator=DataFramesEvaluator(series_evaluator=series_evaluator)dfs_evaluator.evaluate(df1=fruit_basket1,df2=fruit_basket2)index_x  index_y  fruits_equal
0        0        0          True
1        0        1         False
2        1        0         False
3        1        1         False