简体   繁体   中英

How To Replace " . " With " , " on a pandas.DataFrame

I have a dataframe that includes some numbers like 25.300, 27.474 etc. As you can see the digits divided by "." but I need to divide them with ",".

Here is my code:

all_data_df['Column 5'][1:10]= all_data_df['Column 5'][1:10].replace(".",",")

But it doesn't work. How can I fix this issue?

We can replace . by , like so :

all_data_df['Column 5'] = all_data_df['Column 5'].astype(str).str.replace('.', ',', regex=True)

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