1

Here is a sample of my dataframe:

personUID lr diagnosis
1234 65.1 63.38957151969269 90.221 ICD10_R99

When running the following command to sum the values in lr:

TotalRaw['lr_y'] = [
    sum(int(x) for x in string.split()) for string in TotalRaw['lr_y']
]

I receive the following error:

ValueError: invalid literal for int() with base 10: '63.38957151969269'

The values in lr are strings as I had to convert them from float to strings in order to use group_by. Now I can't convert them back to strings nor can I use string.split(), any tips on how to resolve these errors?

1 Answer 1

2

Change:

TotalRaw['lr_y'] = [sum(int(x) for x in string.split()) for string in TotalRaw['lr_y']]

To:

TotalRaw['lr_y'] = [sum(float(x) for x in string.split()) for string in TotalRaw['lr_y']]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.