Skip to content

Instantly share code, notes, and snippets.

@Mengyuz
Created June 5, 2015 15:12
Show Gist options
  • Select an option

  • Save Mengyuz/7d6948354a6c8b0ca564 to your computer and use it in GitHub Desktop.

Select an option

Save Mengyuz/7d6948354a6c8b0ca564 to your computer and use it in GitHub Desktop.
import pandas
def time_to_hour(time):
'''
Given an input variable time that represents time in the format of:
"00:00:00" (hour:minutes:seconds)
Write a function to extract the hour part from the input variable time
and return it as an integer. For example:
1) if hour is 00, your code should return 0
2) if hour is 01, your code should return 1
3) if hour is 21, your code should return 21
Please return hour as an integer.
'''
hour = int(time[0:2])
# your code here
return hour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment