Skip to content

Instantly share code, notes, and snippets.

View pessini's full-sized avatar

Leandro Pessini pessini

View GitHub Profile
@pessini
pessini / download_folder_file_colab.py
Last active December 24, 2022 11:19
How To Download Files And Folders From Google Colab
# 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')
@pessini
pessini / experiment_tracker.py
Created May 24, 2022 23:18
Experiment Tracker to organize ideas and experiments in Machine Learning.
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:
@pessini
pessini / round_up.py
Last active April 26, 2022 19:02
Python uses banker’s rounding but not rounding away from zero. This function is a way to round a number away from zero (including negative numbers).
def round_up(x):
'''
Helper function to round away from zero
'''
from math import copysign
return int(x + copysign(0.5, x))
# 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"
@pessini
pessini / mongodb.py
Created December 2, 2021 08:39
Script to connect and query MongoDB using Python
# 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)