compare_values

compare_values(current, previous, by='feature', value='performance')

Compare a metric between two datasets (e.g. two events or waves).

Joins a current and a previous table on a key column and computes the difference of a metric: for example feature performance from two ipm_model() outputs, or pct from two calc_percentage() tables for two events. The result feeds straight into plot_diff().

The join is a left join keyed on by with previous on the left, so the row set follows the previous period and difference is current - previous (a positive number means it went up). Keys present only in current are dropped; keys missing from current get a missing difference.

Parameters

Name Type Description Default
current pandas.DataFrame Tables sharing a key column and a metric column. required
previous pandas.DataFrame Tables sharing a key column and a metric column. required
by str Name of the key column to join on. Default “feature”. 'feature'
value str Name of the metric column to compare. Default “performance”. 'performance'

Returns

Name Type Description
pandas.DataFrame The key column, previous, current and difference (current - previous).

See Also

plot_diff, ipm_model, calc_percentage

Examples

>>> a = pd.DataFrame({"feature": ["price", "quality"], "performance": [3.1, 4.2]})
>>> b = pd.DataFrame({"feature": ["price", "quality"], "performance": [2.8, 4.4]})
>>> compare_values(current=b, previous=a)