Closed rutgervandeleur closed 4 years ago
thanks @rutgervandeleur, we'll take a look into this.
@rutgervandeleur many thanks for picking this up. As you say, in some cases duplicate values in the index of input datasets will result in errors.
In version 0.7.7 (now on PyPi at https://pypi.org/project/tableone/0.7.7/), we check for duplicate values in the index and will raise an exception if they are found.
In your example, the fix is now to ignore the indexes when concatenating the datasets:
d = pd.concat([d_case, d_control], ignore_index=True)
...or to reset the index after the dataset has been created:
d = pd.concat([d_case, d_control])
d = d.reset_index(drop=True)
Thanks again for raising the issue!
Thank you for fixing this so quickly, it works as expected now!
Thanks @rutgervandeleur, glad to hear this helped. Please do raise new issues for other bugs, annoyances, ideas for improvement etc, and we will try to address them.
There seems to be an issue that when two dataframes are concatenated (for example one with cases and one with controls) the continuous variables' means will be calculated incorrectly. This only happens when the results are grouped (by case/control for example). It seems to be due to the fact that there are duplicate indices in concatenated dataframe, which are then used for mean calculation in both groups.
Example: