Search Tools
Search for cumulative changes in data.
- canomaly.searchtools.cumrexpy(df: DataFrame, target: str, group: str) Series
Apply a cumulative extraction of regular expressions to the grouped values of the target column in a pandas dataframe.
Parameters:
- dfpandas.DataFrame
A pandas DataFrame with columns target and group.
- targetstr
The name of the column to group the values of.
- groupstr
The name of the column to group the values by.
Returns:
- pandas.Series
A new series containing the cumulative extraction of regular expressions applied to the values of the target column grouped by the corresponding values of the group column.
References
Examples
>>> import pandas as pd >>> from canomaly.searchtools import cumrexpy >>> data = {'target': ['apple', 'apple', 'banana', 'banana', 'orange'], 'group': ['a', 'a', 'b', 'b', 'b']} >>> df = pd.DataFrame(data) >>> cumrexpy(df, 'target', 'group') group a [^apple$] b [^[a-z]{5,6}$] Name: target_grouped, dtype: object
- canomaly.searchtools.df_seq_diff(df: DataFrame) DataFrame
Return a dataframe with rows that have at least one changed value compared to the previous row.
Parameters:
- dfpandas.DataFrame
A pandas DataFrame with columns to compare for changes.
Returns:
- pandas.DataFrame
A new dataframe containing the rows of the original dataframe that have at least one changed value compared to the previous row.