There is no string dtype
in pandas
. As noted in the docs:
Note When working with heterogeneous data, the dtype of the resulting ndarray will be chosen to accommodate all of the data involved. For example, if strings are involved, the result will be of object dtype. If there are only floats and integers, the resulting array will be of float dtype.
As far as replacing ,
for .
in your whole dataframe, Use replace
with regex = True
:
df = df.replace(',','.',regex=True)
# or
df.replace(',','.',regex=True, inplace = True)
For example: If your dataframe df
looks like:
>>> df
col1 col2
0 x,x blah,blah
1 y,z hello,world
2 z.z ,.,.,.
Then:
df = df.replace(',','.',regex=True)
>>> df
col1 col2
0 x.x blah.blah
1 y.z hello.world
2 z.z ......