-2
Hello!!! I am looking for help to solve the problem below.
My df has a ' DATA column with format 29/01/2019 17:50:11), which by default is converted to 'object' type pandas. All in all, it has 640 lines. I’ve tried many things, my best advance was.
Create a range for each period and compare them with the column data.
periodo1 = pd.date_range('2020-10-15 05:00','2021-03-18 12:00',freq='1T')
periodo2 = pd.date_range('2020-10-15 12:01','2021-03-18 18:00',freq='1T')
periodo3 = pd.date_range('2020-10-15 18:01','2021-03-18 04:59',freq='1T')
for index, row in df.iterrows( ):
if row ['DATA1'] in periodo1:
df.loc[index,'DATA1'] = 'Manhã'
if row ['DATA1'] in periodo2:
df.loc[index,'DATA1'] = ‘Tarde'
if row ['DATA1'] in periodo3:
df.loc[index,'DATA1'] = 'Noite'
The first part with respect to period1 the Cod. wheel perfectly. However it fills DATA1 (new column), all with 'Morning' and disregards the rest of the code.
Any help is welcome. I thank you in advance.
The simple quote in the late period seems to be using a different encoding, I don’t know if it’s like this in the code or just here on the site, but maybe that’s it. If you copied and pasted the code here, it’s worth taking a look at
– Raizant