Skip to content

Instantly share code, notes, and snippets.

@tmarthal
Last active December 15, 2015 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmarthal/5286991 to your computer and use it in GitHub Desktop.
Save tmarthal/5286991 to your computer and use it in GitHub Desktop.
Python time list filtering
import datetime
base = datetime.datetime.today()
dateList = [ base - datetime.timedelta(minutes=2*x) for x in range(0,48) ]
hour_ago = base - datetime.timedelta(hours=1)
# get the number of dates from less than an hour ago
len(filter(lambda x: x > hour_ago, dateList))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment