Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making column checking robust to passing pandas index #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alistairewj
Copy link
Collaborator

Quick fix - passing an index object to columns causes an error (e.g. t1 = tableone(df, columns=df.columns)). Added a check if it's a pandas index data type since it's probably very common to pass it.

tableone.py Outdated
categorical = self._detect_categorical_columns(data[columns])
elif 'pandas.core.indexes' in str(type(categorical)):
categorical = categorical.get_values()
elif type(categorical) != list:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone specifies a single categorical variable as a string (e.g. categorical = 'ICU'), then I think we now ignore their selection and generate the list ourselves. Might be good to catch the string too?

@tompollard tompollard force-pushed the master branch 3 times, most recently from 9ff9874 to 1db34db Compare November 16, 2019 02:51
@tompollard tompollard force-pushed the master branch 3 times, most recently from 6f62620 to fabcd16 Compare May 6, 2020 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants