Misc
Misc
Random Seed
import random 12) random.seed( 1,2,3,4,5], 2) random.sample([#> [4,3]
Big Data
- {{datatable}}
Misc
- Resources
fread
for fast loading of large datasetsimport datatable as dt # pip install datatable = dt.fread("data/tps_september_train.csv").to_pandas() tps_dt
- For other options (e.g. Dask, Vaex, or cuDF) see this Kaggle notebook
- {{cuDF}}
- {{vaex}}
- {{dask}}
- See MLOps >> Dask
Functions
Suppress warnings
import warnings "ignore") warnings.filterwarnings(
match
/case
Similar to
switch
in R (See R, Base R >> Functions>>switch
Example (source)
def show_options(options: dict|str, str|) -> None: for key, value in options.items(): print(f"{key}: {value}") print() def main(): = {"1": "Add Item", "2": "Delete Item", "3": "View Item", "4": "Exit"} options while True: show_options(options)= input("Choose an option: ") selected_option match selected_option: case "1": print("Add item logic here") # implement add item logic case "2": print("Delete item logic here") # implement view item logic case "3": print("View item logic here") # implement view item logic case "4": print("Goodbye!") break case _: print("Invalid option, please try again") continue