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
# Database connections | |
# create a folder called conn/ and a python file called mongodb with variables for connection | |
from conn import mongodb | |
import importlib | |
from pymongo import MongoClient | |
from urllib.parse import quote_plus | |
importlib.reload(mongodb) | |
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
# Smallest Negative Balance | |
# You are working on a new application for recording debts. This program allows users to create groups | |
# that show all records of debts between the group members. Given the group debt, records (including the | |
# borrower name, lender name, and debt amount), who in the group has the smallest negative balance? | |
# Notes: | |
# -10 is smaller than -1. | |
# if multiple people have the smallest negative balance, return the list in alphabetical order. | |
# if nobody has a negative balance, return the string "Nobody has a negative balance" |
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
def round_up(x): | |
''' | |
Helper function to round away from zero | |
''' | |
from math import copysign | |
return int(x + copysign(0.5, x)) |
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
import sys | |
import pandas as pd | |
import datetime | |
from typing import Union | |
class Score: | |
""" | |
Creates a new object to store scores from different metrics | |
Returns: |
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
# create a zip file from folder you want to download | |
!zip -r /content/file.zip /content/FOLDER_TO_DOWNLOAD/ | |
# download file recently created | |
from google.colab import files | |
files.download("/content/file.zip") | |
# download individual file | |
files.download('/content/sample_data/README.md') |