250x250
Link
λμ GitHub Contribution κ·Έλν
Loading data ...
Notice
Recent Posts
Recent Comments
μΌ | μ | ν | μ | λͺ© | κΈ | ν |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- λ 립νλ³Έ
- μ£Όμ±λΆλΆμ
- λ°μ΄ν°λΆκ· ν
- datascience
- LDA
- DBSCAN
- μΈλμνλ§
- iloc
- λΉ λ°μ΄ν°
- ν¬λ‘€λ§
- numpy
- Python
- μ€λ²μνλ§
- PCA
- λμνλ³Έ
- λ°μ΄ν°λΆμμ λ¬Έκ°
- λΉ λ°μ΄ν°λΆμκΈ°μ¬
- ADP
- μλν΄λΌμ°λ
- ν μ€νΈλΆμ
- opencv
- dataframe
- t-test
- κ΅°μ§ν
- Lambda
- λ°μ΄ν°λΆμ
- λ°μ΄ν°λΆμμ€μ λ¬Έκ°
- ADsP
- pandas
- νμ΄μ¬
Archives
Data Science LAB
[Python] Stack(μ€ν) μ΄μ 리 λ³Έλ¬Έ
728x90
1. μ€νμ΄λ ?
κ°μ₯ λμ€μ λ£μ λ°μ΄ν°λ₯Ό κ°μ₯ λ¨Όμ λΉΌλΌ μ μλ λ°μ΄ν° κ΅¬μ‘°λ‘ Last In First Out(LIFO) λ°©μ, (νΉμ FILO : First In Last Out)
=> νμ΄μ¬μμλ μ΄λ―Έ 리μ€νΈ[]λ‘ κ΅¬νλμ΄μ Έ μμ
2. μ€ν κΈ°λ³Έ μ°μ°
- push()
μ€νμ μμλ₯Ό μΆκ°νλ€. - pop()
μ€ν κ°μ₯ μμ μλ μμλ₯Ό μμ νκ³ κ·Έ μμλ₯Ό λ°ννλ€. - peek()
μ€ν κ°μ₯ μμ μλ μμλ₯Ό λ°ννλ€. (μμ νμ§λ μλλ€.) - empty()
μ€νμ΄ λΉμ΄μλ€λ©΄ 1, μλλ©΄ 0μ λ°ννλ€.
3. μ€ν λΌμ΄λΈλ¬λ¦¬
from collections import deque
dq=deque() # λ± μμ±
dq.append() # λ±μ κ°μ₯ μ€λ₯Έμͺ½μ μμ μ½μ
dq.popleft() # κ°μ₯ μΌμͺ½ μμ λ°ν
dq.appendleft() # λ±μ κ°μ₯ μΌμͺ½μ μμ μ½μ
dp.pop() # κ°μ₯ μ€λ₯Έμͺ½ μμ λ°ν
dp.clear() # λͺ¨λ μμ μ κ±°
dp.copy() # λ± λ³΅μ¬
dp.count(x) #xμ κ°μ μμμ κ°μλ₯Ό κ³μ°
- μ°Έκ³
https://docs.python.org/3.8/library/collections.html#collections.deque
collections — Container datatypes — Python 3.8.14 documentation
collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. namedtuple() factory f
docs.python.org
728x90
'π€ μλ£κ΅¬μ‘° & μκ³ λ¦¬μ¦' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
DFS (κΉμ΄ μ°μ νμ) & BFS (λλΉ μ°μ νμ) (0) | 2023.01.05 |
---|---|
[Python] μλ£νλ³ μκ°λ³΅μ‘λ(Big-O) μ΄μ 리 (0) | 2022.12.28 |
[Python] Deque μ¬μ© λ°©λ² λ° μ¬μ© μ΄μ (0) | 2022.12.23 |
[Python] μ λ ¬ν¨μ (sort, sorted, key=lambda νλΌλ―Έν° μ΄μ© λ°©λ²) μ 리 (0) | 2022.12.04 |
Comments