Home > Mobile >  Replace blank spaces with periods within column in Pandas
Replace blank spaces with periods within column in Pandas

Time:10-14

I have a dataset, df, where within a column I would like to replace the blank spaces with a period.

Data

Date      id
 
Q1 2022   a
Q2 2022   b

Desired

Date      id
 
Q1.2022   a
Q2.2022   b

Doing

df.apply(lambda x: x.str.replace('','.'))

Any suggestion is appreciated

CodePudding user response:

Try with

df['Date'] = df['Date'].str.replace(' ', '.', regex=False)
  • Related