Date and time in the same cell separated

Date and time in the same cell separated

Many times you need to separate the date and time in a cell, as shown in the figure below:

insert image description here

First of all, method 1: it can also be realized by using the column function of Excel. The disadvantage is that there will always be problems in the subsequent pandas analysis.

You can use the following method:

df_1['date']=df_1['日期'].astype(str).apply(lambda x: x.split(" ")[0])
df_1['time']=df_1['日期'].astype(str).apply(lambda x: x.split(" ")[1])
df_1

The result is as follows:

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43697614/article/details/122968056