본문 바로가기

분류 전체보기

(150)
[kill process] How to find the Process ID and Kill it Step 1 : Find the Process ID(PID) of the program There are several ways we can use for finding the PID of a process. # If we know the name of the process pidof # Returns all the running process on the system ps aux | grep -i "name of our desired program" ps aux command returns all the running process on the system. And the grep afterwards shows the line which matches with the program name. ps au..
[src] How do i display local image in markdown? Way 1 : Display local image using parenthesis Create a directory named like 'dirs' and put all the images that will be rendered by the Markdown. For example, put image.png into dirs. To load image.png that was located under the dirs directory before. Note that dirs directory must be located under the same directory of our markdown text file which has .md extension. ![image](dirs/image.png) Way 2..
[Q&A] ELT vs ETL Question : ELT vs ETL, Terminologly wise, one does the load before the transformation and one does it after.. But this doesn't make much sense to me and why it's so important? Answer : It's important for cost and future proofing reasons. The reasons we had ETL before was because storage particulary cloud storage was expensive so we had to limit the data we were writing in our warehouse to keep c..
[div] Colored note boxes inside Jupyter Notebooks NOTE Use blue boxes for Tips and notes. Use green boxes sparingly, and only for some specific purpose that the other boxes can't cover. For example, if you have a lot of related content to link to, maybe you decide to use green boxes for related links from each section of a notebook. Use yellow boxes for examples that are not inside code cells, or use for mathematical formulas if needed. In gene..
[Jupyter] Convert ipynb into pdf Step1 : Open the ipynb extension file Open the ipynb file we want to convert to pdf after running Jupyter. Step2 : Download to html Download to html by clicking file - Download as HTML in the upper left corner. Step3 : Convert to pdf at sejda Source from : https://www.sejda.com/
[gitignore] How to ignore files and directory in repository Step 1 : Create .gitignore To create a .gitignore file, go to the root of our local Git, and create it : $ touch .gitignore Step 2 : Append extensions or directory name to .gitignore Now open the file using a text editor. We are just going to add using wild expression. # ignore ALL .log files *.log # ignore All directory named ipynb_checkpoints .ipynb_checkpoints */.ipynb_checkpoints/* Step 3 : ..
[Error] 5 Common Python Mistakes and How to Fix Them Mistake1 : Indentation and Spaces The Indentation Error can occur when the spaces or tabs are not placed properly. If an indentation error occurs, the transition options of the tabs and spaces on the editor must be changed. Then tabs will automatically be cnaged to 4 spaces. nums = [11, 30, 44, 54] for num in nums: # Using tabs square = num ** 2 # using spaces(4) print(square) # Indentation Eror..
[venv] How to use Virtual Environment with Built-in venv module Step1 : Creating and activating a new virtual environment $ python3 -m venv project_env $ source project_env/bin/activate We can create virtual environment with system-packages(global installation of Python packages). $ python3 -m venv project_env --system-site-package Step2 : Check installed packages on virtual environment $ pip install pytz $ pip list Package Version ------- ------- certifi 20..
[Dictionary] Big-O Efficiency of Python Dictionary 1. Big-O Efficiency of Python Dictionary Operators One important side note on dictionary performance is that the efficiencies are for average performance. Operation Big-O Efficiency copy O(n) get item O(1) set item O(1) delete item O(1) contains (in) O(1) iteration O(n) 2. Comparison of time efficiency of in operator between list and dictionary We will compare the performance of the contains ope..
[List] Big-O Efficiency of Python List 1. Big-O Efficiency of Python List Operators Operation Big-O Efficiency index [] O(1) index assignment O(1) append O(1) pop() O(1) pop(i) O(n) insert(i, item) O(n) del operator O(n) iteration O(n) contains (in) O(n) get slice [x:y] O(k) del slice O(n) set slice O(n+k) reverse O(n) concatenate O(k) sort O(nlogn) multiply O(nk) 2. Comparison of time efficiency of list.pop() method What we would ex..
[time/timeit] Measure the time efficiency of the code 1. What is Algorithm Analysis? An algorithm is a generic, step-by-step list of instructions for solving a problem. It is a method for solving any instance of the problem such that given a particular input, the algorithm produces the desired result. Algorithm analysis is concerned with comparing algorithms based on upon the amount of computing resources that each algorithm uses. We can measure th..
[requests] Interacting with Web Pages 1. What is HTTP and requests module? HTTP stands for Hyper Text Transfer Protocol. WWW is about communication between web clients and servers. Communication between client computer and web servers is done by sending HTTP requests and receiving HTTP Response. The requests module allows us to send HTTP requests using Python. The HTTP requests returns a Response object with all the response data(co..
[R] Classification Problem : Logistic Regression 1. What is Classification Problem? 1.1 Classification The response variable \(Y\) : Qualitative, Categorical feature vector \(X\) ~ qualitative response \(Y\) : \(C(X) \in C\) Interested in estimating the probabilities : \(P(Y=1|X) , P(Y=0|X)\) 1.2 [Ex] Credit Card Default Data # Import Dataset library(ISLR) data(Default) summary(Default) attach(Default) # Visualization of dataset plot(income ~ ..
[Error] pipenv - ModuleNotFoundError Question : On ubuntu, i'm trying to install python package inside Pipenv environment. But, it is giving this error : ModuleNotFoundError : No module name 'distutils.cmd' Answer : The issue is resolved by installing distutils manually with 'sudo apt install python3-distutils'. It is working fine below 3.9.9. Source from : https://github.com/pypa/pipenv/issues/4882
[pipenv] Easily Manage Packages and Virtual Environments 1. What is Pipenv? Pipenv is a tool that aims the best of all packaging worlds to the Python world. It automatically creates and manage a virtualenv for our project, as well as add/removes packages from our Pipfile as our install/uninstall packages. Pipenv is primarily meant to provide users and developers of application with an easy method to setup a working environment. 1.1 What is Pip? Pip is..
[unittest] Unit Testing Our Code 1. What is Unit Testing? Unit testing is a method for testing software that looks at the smallest testable pieces of code, called units, which are tested for correct operation. By doing unit testing, we can verify that each part of the code, including helper functions may not be exposed to the user, works correctly and as intended. # calc.py def add(x, y): """Add Function""" return x + y def sub..
[Syntax] Special arguments *args and **kwargs 1. What is *args and **kwargs arguments? *args allows us to pass a variable number of non-keyword arguments to a Python function. In the function, we should use an atserisk(*) before the parameter name to pass a variable number of arguments.Thus, we're sure that these passed arguments make a tuple inside the function with the same name as the parameter excluding *. **kwargs allows us to pass a v..
[LeetCode] 20. Valid Parentheses 1. Description Givian a string s containing just the characters '(', ')', '{', '}', '[', and ']', determine if the input string is valid. An input string is valid if : Open bracket must be closed by the same type of brackets Open brackets must be closed in the correct order. Every closed bracket has a corresponding bracket of the same type. constraints : 1 check if the current element is same wi..
[LeetCode] 14. Longest Common Prefix 1. Description Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". constraints : 1
[Error] Why does substring slicing with index out of range work? Question : Why doesn't example[999:9999] result in error? Since example[999] does, what is the motivation behind it? Answer : [999:9999] isn't an index, it's a slice, and has different semantics. From the python intro : "Degenerate slice indices are handled gracefully : an index that is too large is replaced by the string size, an upper bound smaller than the lower bound returns an empty string"..