Last active
October 21, 2020 15:53
-
-
Save carlosequiz/ce815e98f66534dafe656412e0c100ae to your computer and use it in GitHub Desktop.
Personal Python Cheat Sheet
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
# 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