Tuesday, 20 October 2020

Pandas is treating integer values as strings while sorting? why?

 convert the values to integer:

df['contig'] = df['contig'].astype(int)
df['pos'] = df['pos'].astype(int)

Then sort with inplace

df.sort_values(by=['contig', 'pos'], inplace=True, ascending=True)


from : https://stackoverflow.com/questions/43396993/pandas-is-treating-integer-values-as-strings-while-sorting-why/43400971

No comments:

Post a Comment

How to check if a file contains a specific string using Bash

 In case if you want to check whether file does not contain a specific string, you can do it as follows. if ! grep -q SomeString "$File...