0
In the database I have a report containing:
INICIO              FINAL
20/07/2021 09:17    20/07/2021 09:25
20/07/2021 09:17    20/07/2021 09:25
20/07/2021 09:17    20/07/2021 09:25
20/07/2021 09:28    20/07/2021 09:33
I need to turn into this:
DATA       HORA INICIO  HORA FINAL
20/07/2021  09:17:10    09:25:17
20/07/2021  09:17:10    09:25:17
20/07/2021  09:17:10    09:25:17
...
I made a code trying two functions
 import pandas as pd
 
 relatorio = pd.read_csv('relatorio.csv', encoding='latin1', sep=';')
 datas_df = relatorio[['INICIO','FINAL']]
 for dhi in datas_df['INICIO']:
    data, hora_inicio = dhi.split(' ')
    datas_df['DATA'] = data
    datas_df['HORA INICIO'] = hora_inicio
    relatorio.append(datas_df['DATA'])
    relatorio.append(datas_df['HORA INICIO'])
 for dhf in datas_df['FINAL']:
    data_f, hora_final = dhf.split(' ')
    datas_df['HORA FINAL'] = hora_final
    relatorio.insert(loc=2, column='HORA FINAL', value=datas_df['HORA FINAL'])
That way the 1st is the error because there is no 'DATA', and in the 2nd is not the error, but only takes the last value of the date and time.
I did with these 2 for to cite examples of methods I have tried.
Can you help? I think it’s something in the loop for right?
Thank you, very helpful!
– HD13sel
@Hd13sel, here at Stack Overflow says thank you by voting in the publications. See: How to say thank you in replies?
– Augusto Vasques