-
Dealing with Missing Values: For dealing with missing values in some columns of training data, one approach is to just drop the columns having missing values. But this is not recommended because the column could have important information. Instead a better approach is to fill in missing values with the column's average using
sklearn.impute.SimpleImputer. -
Dealing with Categorical Data: Categorical data are like Enums - they have one of a fixed set of values (eg.
male,female,other). 2 approaches:
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
| # ANSI escape codes | |
| OSC = "\033]8;;" | |
| ST = "\033\\" | |
| print(f"{OSC}https://example.com{ST}Example Link Text{OSC}{ST}") |
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 tee(it): | |
| it = iter(it) | |
| cache = [] | |
| counts = [0,0] | |
| class _Iterator: | |
| def __init__(self, i, j): | |
| self.i = i | |
| self.j = j |
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 urllib.parse import urlparse, parse_qs | |
| safe_url = 'https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Foneconnect.hcltech.com%2Fnav_to.do%3Furi%3Dsysapproval_approver.do%253Fsys_id%3Dca1525483b4e32101de91624c3e45a99%2526sysparm_record_target%253dsysapproval_approver%2526sysparm_stack%3Dsysapproval_approver_list.do%253Fsysparm_query%3Dsys_created_on%253ejavascript%253ags.beginningOfToday()&data=05%7C02%7Csohang.chopra%40hcltech.com%7Cd4ac502f649d4ea5e89608de407bc9c7%7C189de737c93a4f5a8b686f4ca9941912%7C0%7C0%7C639019097585714357%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Neefy3zdm1PRH0raNr9BS3IzBpNqpt7y4EB07D43tzY%3D&reserved=0' | |
| extracted_url = parse_qs(urlparse(safe_url).query)['url'][0] | |
| print('Extracted URL:', extracted_url) | |
| # Extracted URL: https://oneconnect.hcltech.com/nav_to.do?uri=sysapproval_approver.do%3Fsys_id=ca1525483b4e32101de91624c3e45a99%26sysparm_record_target%3dsysapproval_approver% |
Reference: MathJAX Macros table - macros start with \.
Github Markdown allows a limited subset of MathJAX and no MathJAX extensions can be used.
But in static site generators, extensions can be installed using <script> tag.
Inline expressions are written within $ $, block expressions within $$ $$.
Curly Brackets { } are required for grouping multiple symbols where otherwise only a single character/symbol is expected
- eg. after
_(superscript under) and^(power/subscript over).
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
| # 'Squash Merge' video by anthonywritescode, this is script shown at timestamp 16:50 : | |
| # https://youtu.be/5_8FTivl8Vs?si=krcdLDevrAC_DLuo&t=1013 | |
| # Uses https://github.com/newren/git-filter-repo (python script) | |
| # Explanation: `git cat-file commit COMMIT_ID` shows parent commit id | |
| # normal commits have 1 parent, merge commits have 2 parents | |
| # this script simply deletes 1 parent (keeping only parent id of main branch), | |
| # converting merge commit into normal (squash) commit | |
| # An impressive example of this script is shown, |
$ gpg --full-generate-key
$ gpg --list-secret-keys --keyid-format=long
$ gpg --armor --export GPG_KEY_ID # get key id from prev list command - see details in above linkCopy output of last command (gpg armor export). Go to Github > Settings > SSH and GPG Keys > New GPG Key and paste it.
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
| #! /usr/bin/env python3 | |
| import os | |
| import fitz # PyMuPDF | |
| import nbformat | |
| # Source: https://www.reddit.com/r/learnpython/comments/1ji0qwz/comment/mjblesy/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button | |
| def pdf_to_ipynb(pdf_path: os.PathLike, ipynb_path: os.PathLike) -> None: | |
| """Convert PDF -> Jupyter Notebook .ipynb file.""" | |
| doc = fitz.open(pdf_path) |
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
| {-# LANGUAGE BangPatterns #-} | |
| import Data.List (foldl') | |
| -- | Compresses a string by counting consecutive repeating characters. | |
| -- | |
| -- Returns a list of tuples where each tuple consists of a character and the | |
| -- number of its consecutive occurrences in the string. | |
| -- | |
| -- This function uses 'reverse', 'foldl'' and bang patterns for strict accumulation. |
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
| # Example of forking ziglings repo from CodeBerg to Github | |
| UPSTREAM=https://codeberg.org/ziglings/exercises.git | |
| FORK=git@github.com:sohang3112/ziglings.git # mk empty Github repo & copy SSH url (as Github doesn't support push with HTTPS) | |
| git clone $UPSTREAM ziglings/ # (optional argument) used custom cloned folder name ziglings/ | |
| cd ziglings/ # go to cloned repo | |
| git remote set-url origin $FORK | |
| git remote add upstream $UPSTREAM | |
| git push |
NewerOlder