简体   繁体   中英

Problem with trailing zeros after converting a pandas column to astype(str)

When I use print, without conversion, I got this format:

print(movusumodcir['FUNCAO'])

数字格式,不带零

Then I convert to string, try to remove trailing zeros and print again:

movusumodcir["FUNCAO"] = movusumodcir["FUNCAO"].astype(str)
movusumodcir["FUNCAO"]= movusumodcir["FUNCAO"].str.replace('.0', '')
print(movusumodcir['FU[![pY][1]][1]NCAO'])

Then I got this:

错误

What's wrong? I just want to remove trailing zeros..

movusumodcir["FUNCAO"] = movusumodcir["FUNCAO"].astype(np.str) 

in place of movusumodcir["FUNCAO"] = movusumodcir["FUNCAO"].astype(str)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM