pydit.wrangling.countsΒΆ

Module that implements a few useful count related functions Takes inspiration on the usual counta and countif functions in Excel

  • Add a column counting occurrence of values in a given column. Useful for sorting/grouping by frequency

  • Add a cumulative count of unique keys in a given column

  • Add a column counting the number of null values in a row

  • Add a column counting the number of non-null values in a row

  • Add a column checking if the values in a row are different

  • Add a column counting related keys in another dataframe (e.g., countif)

Functions

count_cumulative_unique

Generates a running total of cumulative unique values in a given column.

count_isna

Returns the number of null values in the columns specified in cols :param df: Dataframe to be analyzed :type df: pd.DataFrame :param cols: List of columns to be analyzed :type cols: list

count_notna

Returns the number of non-null values in the columns specified in cols :param df: Dataframe to be analyzed :type df: pd.DataFrame :param cols: List of columns to be analyzed :type cols: list

count_related_key

Adds column in each df counting occurences of each key in the other dataframe

count_values_in_col

Generates a column counting occurrence of values in a given column.

has_different_values

Returns True if the values in the columns specified in cols are different :param df: Dataframe to be analyzed :type df: pd.DataFrame :param cols: List of columns to be analyzed :type cols: list