tompollard / tableone

Create "Table 1" for research papers in Python
https://pypi.python.org/pypi/tableone/
MIT License
161 stars 38 forks source link

Raise error if input data contains duplicate index. Fixes #101 #102

Closed tompollard closed 4 years ago

tompollard commented 4 years ago

In some cases, duplicate values in the index of an input dataset would result in false information being reported. This fixes the issue by raising an error if the input dataset has duplicate values in the index.

The following chunk steps will now return "InputError: Input data contains duplicate values in the index. Reset the index and try again."

d_control = pd.DataFrame(data={'group': [0, 0, 0, 0, 0, 0, 0],
                         'value': [3, 4, 4, 4, 4, 4, 5]})

d_case = pd.DataFrame(data={'group': [1, 1, 1], 'value': [1, 2, 3]})
d = pd.concat([d_case, d_control])

t = TableOne(d, ['value'], groupby='group', pval=True)