| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
| 31 |
- Github
- PySpark
- PostgreSQL
- Excel
- GIT
- Kotlin
- PANDAS
- hive
- dataframe
- matplotlib
- SQL
- Python
- Java
- array
- math
- Presto
- Google Spreadsheet
- Redshift
- gas
- string
- numpy
- Google Excel
- Apache
- list
- Tkinter
- c#
- django
- google apps script
- 파이썬
- Today
- Total
목록Python/Python Basic (85)
달나라 노트
python filter 함수는 list에서 원하는 데이터만을 filtering할 수 있도록 해줍니다. 바로 예시를 보시죠. list_test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def filter_condition(x): if x >= 5: return x else: pass list_test_new = list(filter(filter_condition, list_test)) print(list_test_new) - Output [5, 6, 7, 8, 9, 10] 위 코드는 1부터 10까지의 저어수를 가진 list에서 5 이상인 정수만을 골라서 list로 만드는 코드입니다. def filter_condition(x) -> 먼저 filter method에서 filtering을 ..
range() range()는 주로 for loop와 함께 쓰이는 함수입니다.어떠한 기능을 가지는지 한번 봅시다. x = list(range(5)) print(x) print(type(x)) - Output [0, 1, 2, 3, 4] range 함수는 인자로서 숫자를 받습니다.위 예시에선 range 함수의 인자로 5라는 숫자가 주어졌습니다. 5라는 숫자를 받은 range함수는 0부터 시작하여 4(=5-1)까지 1씩 증가하는 숫자들을 인자로서 가지게되는 list를 만들어낸다고 생각하면 됩니다. for i in range(5): print(i) - Output 0 1 2 3 4 range는 어떤 숫자를 받아 list를 생성하기 때문에 위 예시처럼 for loop와 함께 사용할 수 있는 것이죠. x = li..
enumerate() list_1 = ['a', 'b', 'c'] for i in list_1: print(i) - Output a b c 위처럼 list는 반복문을 통해서 각각의 요소들에 접근할 수 있습니다. 그러면 만약에 위 반복문에서 요소의 값들(a, b, c) 뿐 아니라 각각의 값들에 대한 index도 받아내고싶으면 어떻게해야할까요? 이를 위해선 여러 가지 방법이 있겠지만 이번에는 enumerate()을 이용해보겠습니다. list_1 = ['a', 'b', 'c'] for i in enumerate(list_1): print(i) print(type(i)) - Output (0, 'a') (1, 'b') (2, 'c') list를 enumerate로 감싼 후 반복문을 실행하면, enumerate는..
class 상속과 super() Python의 class를 다룰 때 자주 언급되는 내용이 상속이라는 것인데, 과연 상속이 뭔지에 대해 한번 간단하게 알아봅시다. 먼저 class를 하나 생성해봅시다. class Parent(): def father(self): print('This is father method.') def mother(self): print('This is mother method.') parent = Parent() parent.father() parent.mother() - Output This is father method. This is mother method. Parent라는 이름의 class를 선언했고 그 class 안에는 fahter와 mother라는 함수가 존재합니다. 그..