일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Google Excel
- c#
- list
- math
- string
- Mac
- Java
- google apps script
- 파이썬
- Github
- Google Spreadsheet
- PANDAS
- Python
- array
- GIT
- SQL
- django
- Redshift
- gas
- dataframe
- matplotlib
- hive
- Excel
- Tkinter
- numpy
- Kotlin
- PySpark
- PostgreSQL
- Apache
- Today
- Total
목록Python/Python Basic (84)
달나라 노트
Python list의 요소를 삭제할 수 있는 기능을 제공하는 method는 크게 4가지가 있습니다. 각 method의 특징은 다음과 같습니다. Method Description clear() list속 모든 요소를 삭제하여 비어있는 list로 변환시킴 (원본 list에서 삭제됨) remove(value) list속에서 value와 동일한 값을 삭제 (원본 list에서 삭제됨) pop(index) list속에서 명시된 index의 요소를 삭제 (원본 list에서 삭제됨) del list[index] list속에서 명시된 index의 요소를 삭제 (원본 list에서 삭제됨) 예시를 보면서 한번 알아봅시다. list_test = [5, 3, 1, 4, 2, 'a', 'bc', 'def'] list_test...
sorted, sort 모두 python의 list 속 요소들을 정렬할 수 있습니다. list_test = [5, 3, 1, 4, 2] list_test.sort(reverse=False) print(list_test) list_test = [5, 3, 1, 4, 2] list_test.sort(reverse=True) print(list_test) -- Result [1, 2, 3, 4, 5] [5, 4, 3, 2, 1] 먼저 sort method를 봅시다. 위처럼 어떤 list에 적용하여 sort가 적용된 list 자체를 정렬시켜버립니다. (sort method는 적용된 list 자체에 변형을 가하고 아무 return값이 없습니다.) 또한 reverse라는 option을 명시하여 오름차순/내림차순 정..
print('AbCdEfG'.lower()) print('AbCdEfG'.upper()) -- Result abcdefg ABCDEFG lower method는 텍스트에 적용하여 모든 알파벳을 소문자로 변경시킵니다. upper method는 텍스트에 적용하여 모든 알파벳을 대문자로 변경시킵니다. print('Ab1C2d3EfG'.lower()) print('Ab4Cd5Ef6G'.upper()) -- Result ab1c2d3efg AB4CD5EF6G 중간에 숫자가 있어도 숫자는 무시하고 알파벳만 대문자 또는 소문자로 바꿔줍니다.
Python에 있는 isnumeric() method는 String type의 데이터에 적용할 수 있으며, 해당 String data가 숫자로 전환될 수 있는 data라면 True, 숫자로 전환될 수 없는 data라면 False를 반환합니다. text1 = '1' print(text1.isnumeric()) text2 = '1a' print(text2.isnumeric()) text2 = 'Text Text' print(text2.isnumeric()) -- Result True False False 위 예시를 봅시다. text1 -> 비록 따옴표로 1이라는 문자가 String으로서 되어있지만, 1은 숫자로 전환될 수 있겠죠? 따라서 isnumeric은 True를 반환합니다. text2 -> 1a는 St..