0

I have a dataframe that has a column where I would like to remove all periods within those values.

Data

Date       ID
Q1.2021    A
Q1.2021    A
Q2.2022    B
Q2.2022    B

Desired

Date       ID
Q1 2021    A
Q1 2021    A
Q2 2022    B
Q2 2022    B

Doing

  def remove_punctuations(text):
    for punctuation in string.punctuation:
        text = text.replace(punctuation, '')
    return text
# Apply to the DF series
df['new_column'] = df['column'].apply(remove_punctuations)

I am thinking I can use a function, however, is there a simpler way? Any suggestion is appreciated

Lynn
  • 4,292
  • 5
  • 21
  • 44

0 Answers0