Skip to content Skip to sidebar Skip to footer

Replacing Periods In Df's Columns

Replacing Periods in DF's Columns I was wondering if there was an efficient way to replace periods in pandas dataframes without having to iterate through each row and call.replace

Solution 1:

df['column'].str.replace('.', '', regex=False)

0    Sam M
Name: column, dtype: object

Solution 2:

Because . is a regex special character so put '\' front of it then it will be good:

Answer :

df['column'].str.replace('\.','')

Example:

df['column']=df['column'].str.replace('\.','')
print(df)

Output:

column0  Sam M

Post a Comment for "Replacing Periods In Df's Columns"