본문 바로가기
728x90
반응형

boolean mask3

[Pandas] isin() 메서드: 가독성 높은 boolean mask 만들기. isin() 메서드란?isin() 메서드는 Series나 DataFrame의 각 element(or item)가 지정된 값 목록에 포함되어 있는지 확인하여 boolean mask를 반환하는 메서드임반환된 boolean mask는 조건부 필터링이나 데이터 선택에 바로 활용가능함.df[df['column'].isin([1, 2, 3])]처럼 대괄호 인덱싱과 함께 사용하여 특정 값들만 포함된 행을 추출하는 용도로 자주 사용됨.특히, 여러 값에 대한 OR 조건을 간단하게 표현할 수 있어 == 연산자를 반복 사용하는 종래의 condition 기반 boolean mask보다 가독성이 높음.2025.08.28 - [Python/pandas] - [Pandas] Boolean Mask 와 where()/mask() [.. 2025. 8. 28.
[ML] where: numpy 의 idx찾기 np.where 함수numpy에서 ndarray 인스턴스에서 특정 조건을 만족하는 elements의 위치(index, idx)를 찾는 기능을numpy 모듈의 where 함수가 제공해줌.사실 where 함수는 특정 조건에 따라 값을 바꾸어주는 기능도 있음.다음 글 참조: https://dsaint31.tistory.com/212 NumPy 검색np.where# np.where는 NumPy의 조건 기반 선택 함수np.where(condition[, x, y]) Return elements chosen from x or y depending on condition.condition : 검색에 사용될 조건.실제로 boolean array가 됨.x : condition이 True에 해당하는 위dsaint31.ti.. 2024. 3. 19.
[DL] Tensor: Indexing <Simple, Slicing, Fancy, Boolean Mask> NumPy나 PyTorch, Tensorflow의 텐서들도파이썬의 list 또는 tubple 에서의 indexing과 slicing이 거의 그대로 사용됨.2023.07.12 - [Python] - [Python] list (sequence type) : summary [Python] list (sequence type) : summarylist는 ordered mutable collection으로, collection을 위한 python data type들 중 가장 많이 사용된다. C에서의 array와 같이 가장 기본적인 collection임. 단, heterogeneous item을 가질 수 있으며, 여러 methods를 가지는ds31x.tistory.com 단, multi-dimension에서 squ.. 2024. 3. 18.
728x90
반응형