์ ์ฒด ๊ธ (34) ์ธ๋ค์ผํ ๋ฆฌ์คํธํ [Python] docstring (๋ฌธ์ํ / ์ฌ์ฉ์ ์ ์ ํจ์ ) ๐ python docstring references: https://wikidocs.net/16050 24. Docstring - ๋ฌธ์ํ - ํ์ด์ฌ์ ์ ํ๋ฉด์, ์ฌ๋ฌ๊ฐ์ง๋ก ๋ฉ์ง๋ค๋ผ๊ณ ์๊ฐํ๋ ๊ฒ ์ค์ ํ๋ - docstring์ ์์ฑํ๋ฉด, ํ๋ก๊ทธ๋๋ฐ์ ์์ฑ์ผ๋ก ์ ๊ทผํ ์ ์์. ## 1. docstring ์ด๋ … wikidocs.net docstring์ ๋ชจ๋, ํจ์, ํด๋์ค ๋๋ ๋ฉ์๋ ์ ์์ ์ฒซ ๋ฒ์งธ ๋ช ๋ น๋ฌธ์ผ๋ก ๋ฐ์ํ๋ ๋ฌธ์์ด ๋ฆฌํฐ๋ด Module ์ฒซ๋ฒ์งธ ์ค, ํจ์ ์ ์ธ ํ ๋ด๋ถ ๋ฐ๋ก ์๋ซ์ค ๋๋ ํด๋์ค ์ ์ธ ํ ๋ด๋ถ ๋ฐ๋ก ์๋ซ์ค์ ํฐ๋ฐ์ดํ 3๊ฐ๋ ์์ ๋ฐ์ดํ 3๊ฐ๋ก ์์ฑํ๋ฉด ๋๋ค. ๐ Docstring ์ฌ์ฉ ์์ def hello(): """์ด ํจ์๋ 'Hello World!'๋ฅผ ์ถ๋ ฅํ๋ค!""" p.. [Python] Pandas Data Analysis ๐ Google Colab ์ ์ด์ฉํด์ Python ์คํ # google drive - google colab ์ฐ๋ from google.colab import drive drive.mount('/content/drive') ๐ Pandas ํ์ผ ๋ถ๋ฌ์ค๊ธฐ import pandas as pd print('pandas version:', pd.__version__) # pandas version: 1.5.3 * boson.csv ํ์ผ ๋ถ๋ฌ์ค๊ธฐ DATA_PATH = '/content/drive/MyDrive/Colab Notebooks/2023/data/' df_boston = pd.read_csv(DATA_PATH + 'boston.csv') df_boston.head(1) df_boston.info() #.. [์ ๋ณด์ฒ๋ฆฌ๊ธฐ์ฌ] ์ค๊ธฐ _ ์ถ์ ์์ ๊ฐ๋ ์ ์ฒด ์์ ์ ๋ฆฌ 1 * 2020๋ 1~4ํ ๊ธฐ์ถ๋ฌธ์ ๋ฐ ํ๊ธฐ ๋ฌธ์ ๊ธฐ๋ฐ์ผ๋ก ์ถ์ ์์ ๊ฐ๋ ์ ๋ฆฌํ ๋ด์ฉ์ ๋๋ค. โ 1. ๋ฐ๋ณต๋ฌธ (for / while - ๋ฒ์ ๋ฐ๋ณต) # ๋ค์ ํ๋ก๊ทธ๋จ์ ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ฐ์์ค. # include void main() { int i = 0, c = 0; while (i < 10) { i++; c *= i; } printf("%d", c); } ๐ก i ๊ฐ 0๋ถํฐ i < 10 ์กฐ๊ฑด์ ๋ง์กฑํ๋ ๋์, while ๋ฌธ ์์ ๋ฌธ์ฅ์ ๋ฐ๋ณตํด์ ์คํ i++ → i = i + 1 c *= i → c = c * i (๊ฒฐ๊ณผ์ ์ผ๋ก, 0 * 1 ์ ๊ฒฐ๊ณผ์ธ 0์ด ๋ค์ c๊ฐ ๋๋ค.) while ๋ฌธ ์ฒ์์ผ๋ก ๋์๊ฐ์ i ๋ ํ์ฌ 1 ์ด๋ฏ๋ก while(i < 10) ์กฐ๊ฑด์ ๋ง์กฑํ๊ณ ๊ณ์ ์คํ๋๋ค. i++ ์คํ ์, i =2 .. [Python] ๊ธฐ์ด๋ฌธ๋ฒ _ Sequence Type (List, Tuple, Dictionary) ๐ List * ๋ฐ๋ณต๋ฌธ์ ๋๋ฆด ์ ์๋ data type ํ์ธ from collections.abc import Sequence my_num = 100 my_list = [1, 2, 3] my_string = "hello" isSeq1 = isinstance(my_num, Sequence) print(isSeq1) # False isSeq2 = isinstance(my_list, Sequence) print(isSeq2) # True isSeq3 = isinstance(my_string, Sequence) print(isSeq3) # True # ๋ฌธ์ํ๋ sequence data ๐ข isinstance() ๐ ์ค์ฒฉ list - item ์ ์์ ๋กญ๊ฒ slicing * Banana ๊ธ์์์ ๋ง์ง๋ง ์ํ๋ฒณ a.. [Python] ๊ธฐ์ด๋ฌธ๋ฒ _ ๋ฌธ์์ด (String) ๐ ๋ฌธ์์ด ์์ x = "Hello World!!" # ๋ฐ๊พธ๊ณ ์ถ์ ๊ฒ, Aello World!! x[0] = "A" print(x[0]) x = "Hello World!!" x = 'A' + x[1:] x ๐ AttributeError ๐ python string methods documentation → https://docs.python.org/3/library/stdtypes.html#str โ python string method - upper() โ python string method - replace() โ python string method - split() [Python] Comprehension (List, Dictionary, Tuple) ๐ List Comprehension ๐ ๋ฆฌ์คํธ ์์ฑํ๊ธฐ * 1~10๊น์ง ์ ์๋ฅผ ์์๋๋ก ๊ฐ์ง๊ณ ์๋ ๋ฆฌ์คํธ๋ฅผ ์์ฑํ๋ ์ฝ๋ numbers = [] for n in range(1, 10+1): numbers.append(n) * ๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์ (List Comprehension) : ๋ฆฌ์คํธ๋ฅผ ์์ฑํ๋ ์ปดํ๋ฆฌํจ์ [x for x in range(10)] ๐ for ๋ฌธ๊ณผ ๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์ ๋น๊ต → ๊ณตํต์ : ๋ฆฌ์คํธ๋ฅผ ์์ฑํ๋ ๋ฐฉ์์ ๋๊ดํธ([ ]) ๋ฅผ ํตํด ์์ฑ → ์ฐจ์ด์ : ๋ฆฌ์คํธ ์ปดํ๋ฆฌํจ์ ์ ๋ฆฌ์คํธ ๋ด๋ถ์ ์ฝ๋๋ฅผ ์์ฑ * 1~10๊น์ง ์ซ์ ์ค ์ง์๋ง ์์ฐจ์ ์ผ๋ก ๋ค์ด์๋ ๋ฆฌ์คํธ ์์ฑํ๊ธฐ * for๋ฌธ even_numbers = [] for n in range(1, 10+1): if n % 2 == 0: e.. [References] Machine Learning in R Tidy Modeling with R https://www.tmwr.org/ Tidy Modeling with R The tidymodels framework is a collection of R packages for modeling and machine learning using tidyverse principles. This book provides a thorough introduction to how to use tidymodels, and an outline of good methodology and statistical practice for phases www.tmwr.org Caret Package http://appliedpredictivemodeling.com/ Applied Pred.. [Linux] ๋ช ๋ น์ด & vi editor ์ค์ต # ์ง๋ฌธ์ ๋ตํ๊ธฐ 1. Linux ๋ช ๋ น์ด ์ค์ต 2. vi editor ์ค์ต #1. Linux ๋ช ๋ น์ด ์ค์ต ** ์ค์น ์ ๋ช ๋ น์ด [Ubuntu] apt-get [Centos] dnf ** RunLevel ์ค์ต # Cd /lib/systemd/system ์ผ์ชฝ๋ถํฐ ์ต์์ ๋๋ ํ ๋ฆฌ # Pwd - ํ์ฌ์์น ํ์ธ # cd ๋ง ์น๋ฉด ํ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํจ ** Test ๊ณ์ ๊ฐ๋ ค๋ฉด : su test Test ๊ณ์ ์ํ์์๋ root ํ๊ฐ ๊ฑฐ๋ถ [test@localhost ~ ] Test : ๊ณ์ ์ด๋ฆ Localhost : ๋๋ฉ์ธ ํ๋๋ ํ ๋ฆฌ ์์๊ฒฝ์ฐ ~ ์ผ๋ฐ ์ฌ์ฉ์ - [ ]$ ๋ฃจํธ - [ ]# ํ์ฌ ์์น๊ฐ ์๋ฌด๋ฆฌ ๋ฉ๋ฆฌ ์์ด๋ $ cd ~ ์ ๋ ฅํ๋ฉด ํ๋๋ ํ ๋ฆฌ๋ก ์ด๋ Root ์ํ์์ # cd /lib/systemd/sys.. ์ด์ 1 2 3 4 5 ๋ค์