I run the program:
import pandas
df=pandas.DataFrame([['11-20','a',1],['10-20 更新于16-10-20 18:07','b',2],['15-12-27','c',3],['15-10-26 更新于10-26 23:52','d',4]],columns=['date','name','type'])
df.date=df.date.str.replace('^(\d+)(-)(\d+)((-)\d+){0,1}(.*)','\1\2\3\4')
print df
this is the result:
date name type
0 a 1
1 b 2
2 c 3
3 d 4
I want to get the result:
date name type
0 11-20 a 1
1 10-20 b 2
2 15-12-27 c 3
3 15-10-26 d 4
I also check this regex at https://regex101.com/r/apIT0O/8 . But I do not know where the problem is.
source
share