| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- PANDAS
- Excel
- Google Excel
- list
- Tkinter
- Apache
- matplotlib
- SQL
- PySpark
- array
- string
- dataframe
- Python
- c#
- django
- Redshift
- Kotlin
- math
- GIT
- gas
- Google Spreadsheet
- Java
- PostgreSQL
- google apps script
- Presto
- 파이썬
- numpy
- hive
- Github
- Today
- Total
목록Python/Python Basic (85)
달나라 노트
Syntax dictionary.setdefault(key, default_value) setdefault method는 dictionary에 적용할 수 있는 method이며 2개의 인자를 받습니다. - key setdefault method는 전달받은 key값에 대한 value를 dictionary에서 찾아 return 해줍니다. - default_value 만약 전달받은 key값이 dictionary에 없을 경우 default_value를 return합니다. dict_test = { 'key1': 1, 'key2': 2, 'key3': 3 } val_result_1 = dict_test.setdefault('key1', 10) print(val_result_1) -- Result 1 위 예시를 봅시다..
list에 적용할 수 있는 append, extend method를 알아보고 이 둘의 차이에 대해 알아보겠습니다. Syntax list.append(element) append method는 parameter로서 받은 값을 list의 가장 오른쪽에 추가해줍니다. Syntax list.extend(iterable_value) extend method는 iterable type의 값을 받아 그 값들을 list의 가장 오른쪽에 단일 요소로서 추가해줍니다. iterable type의 값을 받는다는 것은 list, set, tuple, dictionary 등의 값을 받는다는 것입니다. 9, 'value1' 등의 단일 값을 전달하면 extend는 오류를 발생시킵니다. 여기까지 보면 설명이 잘 이해되지 않아도 app..
list의 pop method는 특정 index에 위치한 요소를 제거하고 제거된 요소를 return해줍니다. 그리고 원본 list에도 명시된 index 위치에 있는 요소가 제거된 채로 변형됩니다. Syntax list.pop(index) pop method는 제거할 요소의 index를 parameter로 받습니다. list_test = [1, 2, 3, 4, 5] removed_element = list_test.pop(1) print(removed_element) print(list_test) -- Result 2 [1, 3, 4, 5] list_test.pop(1) -> 이것의 의미는 list_test에서 index = 1 위치에 있는 요소를 제거한 후 제거된 그 요소를 return합니다. 그래서 결..
Python을 다루다보면 아래와 같은 함수를 볼 수 있습니다. def test_1(*args): ... def test_2(**kwargs): ... 함수의 내용은 중요한게 아니라서 ...으로 생략하여 표시하였습니다. 중요한건 함수의 parameter 부분입니다. 보통 함수에서 parameter를 설정할 때 특정 키워드를 괄호안에 넣어두죠. 근데 위 함수를 보면 *(asterisk)를 이용하여 *args, **kwargs 라는 이상한 parameter를 넣어놨습니다. 이것은 당연히 일반적인 parameter와는 조금 다른 기능을 가지며 저것들이 대체 무엇을 의미하고 어떤식으로 사용할 수 있는지를 알아봅시다. 일단 상황을 한번 가정해봅시다. 여러분이 여러 개의 값들을 사용자로부터 input받아서 이 값들을..
