Here's a working example:
df = pd.DataFrame({'A': [-39882300000000000000]}, dtype='object')
df.replace({',': '.'})
raises an OverflowError
because somewhere in the code the convert
flag is set to True. I am not sure but it is probably because pandas is inferring that it only contain numbers.
I read the data from an Excel workbook and I want to prevent this conversion when using df.replace
. Is there a way to do so?
Pandas. DataFrame doesn't preserve the column order when converting from a DataFrames.
errors{'ignore', 'raise', 'coerce'}, default 'raise' If 'raise', then invalid parsing will raise an exception. If 'coerce', then invalid parsing will be set as NaN. If 'ignore', then invalid parsing will return the input.
In the same way you can't attach a specific data type to list , even if all elements are of the same type, a Pandas object series contains pointers to any number of types.
df.update(df.blocks['object'].astype(str).replace({',': '.'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With