일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- PYTHON
- CSS
- matplotlib
- ngs
- CUTandRUN
- EdgeR
- 비타민 C
- scRNAseq
- drug muggers
- single cell
- MACS2
- Bioinformatics
- python matplotlib
- javascript
- single cell analysis
- HTML
- julia
- Git
- Batch effect
- scRNAseq analysis
- 싱글셀 분석
- pandas
- ChIPseq
- github
- js
- single cell rnaseq
- drug development
- DataFrame
- CUT&RUN
- cellranger
Archives
- Today
- Total
바이오 대표
[ Python ] 두개의 array 비교하기 (np.array_equal, (A==B).all()) 본문
Python/array (numpy)
[ Python ] 두개의 array 비교하기 (np.array_equal, (A==B).all())
바이오 대표 2022. 3. 13. 10:16
np.array_equal(A,B)
Array A와 B의 형태(shape)과 요소들(elements)이 동일하다면 True 아니면 False 를 반환한다
(A == B).all( )
해당 function을 이용할 수 도 있지만, 몇가지 특정 상황에서 두서없이 True 를 반환한다.
주의 사항:
- A 나 B 중 하나가 empty array 이고 다른 하나가 1개의 element 를 갖을 때 True 를 반환한다
- A == B 는 empty array를 반환한다
- A 와 B의 형태(shape)이 같지 않을때, error를 띄운다
# 다른 비교 방법
np.array_equal(A,B) # test if same shape, same elements values
np.array_equiv(A,B) # test if broadcastable shape, same elements values
np.allclose(A,B,...) # test if same shape, elements have close enough values
'Python > array (numpy)' 카테고리의 다른 글
[ Python ] 구조의 재배열 numpy.reshape (0) | 2022.02.15 |
---|---|
[ Python ] NumPy Array 데이터 csv (ASCII) 로 저장하기 (to_csv( ), savetxt( )) (0) | 2022.02.06 |