Suppose you have:
df_new=pd.DataFrame()
df_new['name']=['Punto','Doblo','Doblo','Punto','Punto','Tipo']
df_new['date']=['20200124_083155','20200124_163540','20200124_122052','20200124_150801',
'20200124_134350','20200124_195955']
output:
name date
0 Punto 20200124_083155
1 Doblo 20200124_163540
2 Doblo 20200124_122052
3 Punto 20200124_150801
4 Punto 20200124_134350
5 Tipo 20200124_195955
Use shift with groupby:
df_new['date2']=df_new.groupby('name').shift(-1)
df_new['date2']=';'+df_new['date2']
df_new['date2']=df_new['date2'].fillna('')
output:
name date date2
0 Punto 20200124_083155 ;20200124_150801
1 Doblo 20200124_163540 ;20200124_122052
2 Doblo 20200124_122052
3 Punto 20200124_150801 ;20200124_134350
4 Punto 20200124_134350
5 Tipo 20200124_195955
if you want to see it in the same column:
df_new['date3']=df_new['date']+df_new['date2']
output:
name date date2 date3
0 Punto 20200124_083155 ;20200124_150801 20200124_083155;20200124_150801
1 Doblo 20200124_163540 ;20200124_122052 20200124_163540;20200124_122052
2 Doblo 20200124_122052 20200124_122052
3 Punto 20200124_150801 ;20200124_134350 20200124_150801;20200124_134350
4 Punto 20200124_134350 20200124_134350
5 Tipo 20200124_195955 20200124_195955
It is not concise. But this approach will ensure that you only have two dates in the column. Unlike with groupby and transform method