I have a dataframe such as :
query qstart qend name number strand
A 2.0 1064.0 None 0 +
B 2.0 1076.0 None 0 +
C 2.0 1064.0 None 0 +
D 0.0 741.0 None 0 +
and I would like to remove all decimals and get :
query qstart qend name number strand
A 2 1064 None 0 +
B 2 1064 None 0 +
C 2 1064 None 0 +
D 0 741 None 0 +
I tried:
df['qstart']= round(df['qstart'])
df['qend']= round(df['qend'])
but it does not work...
Try the below:
m=(df.dtypes=='float')
df.loc[:,m]=df.loc[:,m].astype(int)
print(df)
query qstart qend name number strand
0 A 2 1064 None 0 +
1 B 2 1076 None 0 +
2 C 2 1064 None 0 +
3 D 0 741 None 0 +
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With