calculate_random_expectation
Calculates the random expectation of responsiveness in a DataFrame.
This function takes a DataFrame that contains a ‘responsive’ column with boolean values. It calculates the proportion of rows marked as responsive and unresponsive, and then computes the expected random proportion of responsiveness.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A DataFrame containing at least a ‘responsive’ |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame: A DataFrame with columns ‘unresponsive’, ‘responsive’, |
|
and ‘random’, where ‘unresponsive’ and ‘responsive’ are counts of each |
|
category, and ‘random’ is the proportion of responsive rows over the |
|
total number of rows. |
Example
df = pd.DataFrame({‘responsive’: [True, False, True, False]}) calculate_random_expectation(df)
Returns a DataFrame with the counts of responsive and unresponsive¶
rows and the proportion¶
of responsive rows.¶
Source code in callingcardstools/Analysis/yeast/rank_response/calculate_random_expectation.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|