반응형
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 | 31 |
Tags
- list
- hive
- Redshift
- Google Excel
- PostgreSQL
- Apache
- string
- GIT
- django
- 파이썬
- numpy
- array
- PySpark
- math
- c#
- Google Spreadsheet
- PANDAS
- Kotlin
- SQL
- google apps script
- Mac
- Java
- matplotlib
- gas
- dataframe
- Excel
- Python
- Tkinter
- Github
Archives
- Today
- Total
목록dictionary정렬 (1)
달나라 노트
Python Basic : sorted method를 이용한 dictionary 정렬, dictionary 정렬하기
dictionary의 값들을 정렬하는 방법에 대해 알아보겠습니다. dict_test = { 3: 'c', 5: 'a', 4: 'b', 1: 'e', 2: 'd', } list_test_sorted = sorted(dict_test.items(), key=lambda x: x[0], reverse=False) dict_test_sorted = dict(list_test_sorted) print(dict_test_sorted) -- Result {1: 'e', 2: 'd', 3: 'c', 4: 'b', 5: 'a'} 위 예시를 봅시다. 초기 dict_test에 정의된 값들은 key가 1, 2, 3, 4, 5가 있는데 전혀 정렬이 되어있지 않습니다. 그래서 sorted method를 이용해서 정렬을 했더니 결..
Python/Python Basic
2022. 1. 16. 19:51