Home > Net >  How to split text into new column within the same data frame
How to split text into new column within the same data frame

Time:05-27

How can I move the date into a new column within the same data frame

enter image description here

CodePudding user response:

IIUC you can just split the column

df['New_Column'] = df.['Date Time'].apply(lambda x : str(x).split()[1])
df

CodePudding user response:

You can try

df['Date'] = df['Date Time'].str.split(' ').str[0]

# or

df['Date'] = pd.to_datetime(df['Date Time']).date
  • Related