Skip to content

Commit

Permalink
Fix NAs in grouping variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Kahle committed Oct 5, 2023
1 parent a3a62cb commit 7f91c11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion statistikem.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def compare_one(var, grouping=None, data=None, plot=True, summary=False,
if not scale:
scale = _guess_scale(var.values.flatten())
if scale == 'binary':
res = paired_proportion_test(var, plot=plot, scale=scale, **kwa)
warnings.warn('paired_proportion_test not implemented.')
# res = paired_proportion_test(var, plot=plot, scale=scale, **kwa)
elif scale == 'categorical' or scale == 'continuous':
res = paired_difference_test(var, plot=plot, scale=scale, **kwa)
else:
Expand Down Expand Up @@ -662,6 +663,12 @@ def fix_column_names(df):
df.columns = [regex.sub('_', col).strip('_') for col in df.columns]

def _split_to_groups(var, grouping):
grouping_na = grouping.isna()
grouping_na_sum = grouping_na.sum()
if grouping_na_sum > 0:
var = var[~ grouping_na]
grouping = grouping[~ grouping_na]
warnings.warn(f'{grouping_na_sum} rows removed because of missing values in grouping variable.')
na_loc = var.isna()
var_nona = var[~ na_loc]
grp_nona = grouping[~ na_loc]
Expand Down

0 comments on commit 7f91c11

Please sign in to comment.