I try to replace only one caracter of a string in a pandas columns. Concretly, I want to replace . by - in the "Date" columns
Here is my script :
import pandas as pd
number = {"date": [2002.04, 2002.05], "team": ["a", "b"]}
number_pandas = pd.DataFrame(number)
number_pandas
number_pandas.date.replace(".", "-")
Here is the output :
0 2002.04
1 2002.05
Name: date, dtype: float64
It does not work. Maybe you can help with Regex.
number_pandas['date'].astype(str).str.replace(".", "-", regex=False)?