반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Tkinter
- matplotlib
- Excel
- 파이썬
- Java
- GIT
- Google Excel
- SQL
- django
- hive
- Redshift
- array
- string
- numpy
- dataframe
- Mac
- PySpark
- math
- google apps script
- Python
- Apache
- Kotlin
- Github
- Google Spreadsheet
- PostgreSQL
- list
- gas
- c#
- PANDAS
Archives
- Today
- Total
달나라 노트
Python Basic : set.intersection (set 교집합 구하기) 본문
728x90
반응형
intersection
intersection은 python의 collection중 하나인 집합을 다루는 set의 교집합을 반환합니다.
아래 예시는 set_1과 set_2의 교집합을 구하는 예시입니다.
set_1 = {1, 2, 3, 4, 5}
set_2 = {2, 3, 5, 6, 8}
print(set_1)
print(set_2)
x = set_1.intersection(set_2)
print(x)
- Output
{1, 2, 3, 4, 5}
{2, 3, 5, 6, 8}
{2, 3, 5}
set_1과 set_2의 공통 요소인 2, 3, 5만 교집합으로서 반환되었음을 알 수 있습니다.
728x90
반응형
'Python > Python Basic' 카테고리의 다른 글
Python Basic : class 상속과 super() (0) | 2020.11.29 |
---|---|
Python Basic : assert (True, False 확인하고 False인 경우 코드 중단하기) (0) | 2020.11.23 |
Python Basic : set.union (set 합집합 구하기) (0) | 2020.11.23 |
Python Basic : break, pass, continue (0) | 2020.11.18 |
Python Basic : if ~ elif ~ else, for loop, while loop, def (조건문, 반복문, 함수 선언, 한 줄 조건문, 한 줄 if, 한 줄 for loop, 한 줄 for 구문) (0) | 2020.10.29 |
Comments