Created
June 14, 2018 11:52
-
-
Save wellmotta/48563e91087bd4be4bf0ed1115bdffeb to your computer and use it in GitHub Desktop.
306912-stackoverflow created by wellmotta - https://repl.it/@wellmotta/306912-stackoverflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def periodo(linha): | |
horario = linha['hora completa'] | |
if '06:00:00' < horario < '11:59:00': return 'Manha' | |
elif '12:00:00' < horario < '17:59:00': return 'Tarde' | |
elif '18:00:00' < horario < '23:59:00': return 'Noite' | |
elif '00:00:00' < horario < '05:59:00': return 'Madrugada' | |
return '' | |
df = pd.DataFrame({'hora completa':['21:35:00', '22:16:00', '00:50:00', '09:30:00', '14:30:00']}) | |
df['periodo'] = df.apply(periodo, axis=1) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment