You can use applymap:
df[["Lon_X", "Lat_Y"]] = df[["Lon_X", "Lat_Y"]].applymap(lambda x: float(x.replace(",", ".")))
df
Here is some benchmark about these alternatives, to_float_inplace is significantly faster than all other methods:
Data:
df = pd.DataFrame({"Lon_X": ["5,234234" for i in range(1000000)], "Lat_Y": ["6,3234234" for i in range(1000000)]})
# to_float_inplace
def to_float_inplace(x):
x[:] = x.str.replace(',', '.').astype(float)
%timeit df.apply(to_float_inplace)
# 1 loops, best of 3: 269 ms per loop
# applymap + astype
%timeit df.applymap(lambda x: x.replace(",", ".")).astype(float)
# 1 loops, best of 3: 1.26 s per loop
# to_float
def to_float(x):
return x.str.replace(',', '.').astype(float)
%timeit df.apply(to_float)
# 1 loops, best of 3: 1.47 s per loop
# applymap + float
%timeit df.applymap(lambda x: float(x.replace(",", ".")))
# 1 loops, best of 3: 1.75 s per loop
# replace with regex
%timeit df.replace(',', '.', regex=True).astype(float)
# 1 loops, best of 3: 1.79 s per loop