Skip to content

Instantly share code, notes, and snippets.

@carlosequiz
Last active October 21, 2020 15:53
Show Gist options
  • Save carlosequiz/ce815e98f66534dafe656412e0c100ae to your computer and use it in GitHub Desktop.
Save carlosequiz/ce815e98f66534dafe656412e0c100ae to your computer and use it in GitHub Desktop.
Personal Python Cheat Sheet
# Getting class name
MyClass(x).__name__
# UTC timestamp 2020-03-04T17:50:26.376Z
now = datetime.datetime.utcnow()
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \
'.%03d' % (now.microsecond / 1000) + 'Z'
# Jupyter arguments
NOTEBOOK_ARGUMENTS = [
"--ip",
"0.0.0.0",
"--allow-root",
"--no-browser",
]
###############################################
# Looback business days
from datetime import datetime
from workalendar.usa import UnitedStates
date_time_transaction = '2020-09-28T13:39:05.596Z'
date_time_obj = datetime.strptime(date_time_transaction, '%Y-%m-%dT%H:%M:%S.%fZ')
cal = UnitedStates()
cal.add_working_days(date_time_obj, -3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment