0
COD_CUST  
 10025.0   
 10761.0  
 10869.0    
 12361.0 

trying to convert the above column into integer as below:

mser_offus['COD_CUST']=mser_offus['COD_CUST'].astype(int)

but getting the following error:

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

2
  • Do you need remove .0 only and cast to int? Commented Apr 6, 2018 at 10:39
  • need to remove .0 Commented Apr 6, 2018 at 10:46

2 Answers 2

0

IIUC if need remove all values after . and convert to int:

df['COD_CUST'] = df['COD_CUST'].astype(float).astype(int)
print (df)
   COD_CUST
0     10025
1     10761
2     10869
3     12361
Sign up to request clarification or add additional context in comments.

Comments

0

you may use, print (int(float(COD_CUST)))

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.