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

Change add_annotations error handling #2

Open
tobsecret opened this issue Nov 27, 2020 · 0 comments
Open

Change add_annotations error handling #2

tobsecret opened this issue Nov 27, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@tobsecret
Copy link
Collaborator

Sometimes a column looks like it's continuous, but fails to convert to float, like e.g. Cigarettes.per.Day which was drawn from a questionnaire which offered 0, 1, 3, 5, ... and the option Unknown. As a result of this, add_annotations will throw an error, saying it cannot convert 'Unkown' to float. This should probably be wrapped in a try/except statement that tells you which columns it had trouble converting. Not entirely sure if it'll be like in the code below, but it's just a sketch for now.

try: 
        self.continuous_annotations = annotations[
            annotations.columns[column_types == 1]
        ].astype(float)
except ValueError:
        for column in annotations.columns[column_types == 1]:
                if not check_column_float_convertible(annotations.loc[:,column]):
                        logging.error(f'{column} column cannot be converted to float, check unique values')
        ValueError("Unable to convert columns to float")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant