gini_coefficient module
- utils.gini_coefficient.get_gini(input_data, on_column, conversation_id_col)
Calculates the Gini coefficient for a specified numeric column within grouped conversation data.
- Parameters:
input_data (pd.DataFrame) – A DataFrame of conversations, where each row represents one chat.
on_column (str) – The name of the numeric column on which the Gini coefficient is to be calculated.
conversation_id_col (str) – A string representing the column name that should be selected as the conversation ID.
- Returns:
A DataFrame with Gini coefficients for each conversation.
- Return type:
pd.DataFrame
- utils.gini_coefficient.gini_coefficient(x)
Calculates the Gini coefficient for an array of values, which is a measure of statistical dispersion.
Source code: https://stackoverflow.com/questions/39512260/calculating-gini-coefficient-in-python-numpy
- Parameters:
x (list or np.ndarray) – List or array of values to calculate the Gini coefficient for.
- Returns:
Gini coefficient value.
- Return type:
float