source:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
from __future__ import annotations | |
from functools import lru_cache, wraps | |
from psycopg2 import connect | |
from pandas import read_sql, DataFrame | |
class RedshiftDB: | |
"""Redshift Database Hook | |
USAGE: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# --- Code Book: Python Algorithms | |
# --- Source : github.com/keon/algorithms.git | |
#======================================================================================================================== | |
# :: tree/path_sum.py :: | |
#======================================================================================================================== | |
| 1| """ | |
| 2| Given a binary tree and a sum, determine if the tree has a root-to-leaf | |
| 3| path such that adding up all the values along the path equals the given sum. | |
| 4| |
This file contains hidden or 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
def distance(u, v): | |
""" | |
Calculates Euclidean distance between two point | |
distance = square_root( sum(u_i - v_i)^2 ) | |
u: [float, float], point1 | |
v: [float, float], point2 | |
""" | |
sum_ = sum((u[i] - v[i]) ** 2 for i in range(len(u))) | |
return sum_ ** (1 / 2) |