| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- Redshift
- Github
- hive
- Google Excel
- numpy
- GIT
- Tkinter
- matplotlib
- django
- math
- c#
- list
- Apache
- Presto
- Java
- SQL
- PANDAS
- Python
- Kotlin
- PySpark
- PostgreSQL
- Excel
- dataframe
- gas
- Google Spreadsheet
- 파이썬
- string
- array
- google apps script
- Today
- Total
목록Python (388)
달나라 노트
import datetime a = datetime.datetime(12, 34, 56, 12, 34, 56, 123456) b = datetime.datetime(12, 34, 56) print(a) print(b) - Result 2020-03-08 12:34:56.123456 2020-03-08 00:00:00 datetime module에는 datetime이라는 class가 존재합니다. datetime method는 datetime class의 생성자(Constructor)이며 년, 월, 일, 시, 분, 초, 마이크로초의 7개 인자를 받으며 이 중 년, 월, 일은 필수 인자입니다. 만약 입력되지 않은 인자는 모두 0으로 인식되는 것을 위 예시의 b에서 볼 수 있습니다. import datetime..
import datetime a = datetime.time() print(a) b = datetime.time(12, 34, 56) print(b) c = datetime.time(hour = 12, minute = 34, second = 56,) print(c) d = datetime.time(12, 34, 56, 123456) print(d) - Result 00:00:00 12:34:56 12:34:56 12:34:56.123456 datetime module에는 time이라는 class가 존재합니다. time method는 time class의 생성자(Constructor)이며 시간, 분, 초의 세 가지 parameter를 기본적으로 받고, 거기에 추가로 d처럼 1초 미만의 소수점 초까지 par..
import datetime today = datetime.date.today() y = today.year m = today.month d = today.day w = today.weekday() print(y) print(m) print(d) print(w) - Result 2020 3 8 6 datetime 모듈의 date class에 today method를 사용하거나 직접 년, 월, 일을 입력해주어 date 객체를 생성합니다. 이 생성한 date class의 year, month, day attribute를 이용하여 년, 월, 일을 추출할 수 있으며 weekday method를 이용하여 요일별 숫자(월 = 0, 화 = 1, ... 일 = 6)를 얻어낼 수 있습니다.
import datetime d = datetime.date.fromtimestamp(1583644364) print(d) - Result 2020-03-08 date 객체 생성 시 년, 월, 일을 받지 않고 fromtimestamp method를 사용하여 Unix timestamp를 날짜로 변환하여 얻을 수 있습니다. Unix timestamp는 1970년 1월 1일(UTC)부터 몇 초가 흘렀는지를 나타내는 수치입니다.