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

Caution on sampleids coercable to integers #3

Open
nickp60 opened this issue Feb 7, 2025 · 1 comment
Open

Caution on sampleids coercable to integers #3

nickp60 opened this issue Feb 7, 2025 · 1 comment

Comments

@nickp60
Copy link

nickp60 commented Feb 7, 2025

Hello! This is a minor edge case but I'm posting in case anyone else runs into the issue. In cases where the given sample name consists of digits, it appears that pandas is coercing the column to integers, which breaks the logic here with an error:

    out = sample_file.split('/')[-1]
          ^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'split'

I think adding something like the following should sort it out.

            df = pd.read_csv(sylph_result, sep='\t')
            df.sample_name = df.sample_name.astype(str)

Thanks for all your efforts!

Nick

@bluenote-1577
Copy link
Owner

Hi Nick,

Thanks for catching this. I can reproduce the bug and have added a fix as you've suggested:

df['Sample_file'] = df['Sample_file'].astype(str)

Pushing a new version now -- you may have to do pip install sylph-tax/ on the cloned version since it won't be on conda right away.

P.S. this is why I hate python...

Thanks

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

No branches or pull requests

2 participants