일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- hive
- PANDAS
- 파이썬
- PostgreSQL
- string
- dataframe
- Redshift
- Mac
- SQL
- Tkinter
- google apps script
- Excel
- gas
- matplotlib
- array
- Kotlin
- list
- django
- numpy
- Java
- c#
- PySpark
- math
- Google Spreadsheet
- GIT
- Github
- Python
- Google Excel
- Apache
- Today
- Total
목록Python (384)
달나라 노트
Python의 datetime library에는 utcnow라는 method가 있는데 이것은 현재 기준 UTC를 반환해줍니다. import datetime dt_utc = datetime.datetime.utcnow() print(dt_utc) -- Result 2021-10-27 17:08:51.097881 사용법은 상당히 간단합니다. utcnow() method만으로 UTC를 얻을 수 있습니다. utcnow()는 Python코드를 실행하는 서버나 컴퓨터의 시간에 상관없이 UTC값을 기준으로 계산되는 것이므로, 혹시나 컴퓨터의 시간이 이상하다거나 사용하는 서버의 시간이 이상할 경우 정확한 현재 시간/날짜를 얻기 위해 사용할 수 있습니다. import datetime dt_kst = datetime.da..
Pandas에서 제공하는 to_list method는 Series에 적용할 수 있으며 적용된 Series를 list 형태로 변환해주는 역할을 합니다. import pandas as pd dict_main = { 'col1': [1, 2, 3, 4, 5, 6], 'col2': ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta'] } df_main = pd.DataFrame(dict_main) print(df_main) list_col2 = df_main.loc[:, 'col2'].to_list() print(list_col2) list_col2 = list(df_main.loc[:, 'col2']) print(list_col2) -- Result col1 col..

tabulate을 이용하여 DataFrame을 terminal에서 더 가독성 좋게(이쁘게) 출력하는 방법을 알아봅시다. import pandas as pd dict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': ['Apple', 'Banana', 'Watermelon', 'Grape', 'Melon'], 'col3': ['a', 'b', 'c', 'd', 'e'], } df_test = pd.DataFrame(dict_test) print(df_test) 위 코드를 실행해보면 그 결과로 아래 이미지와 같은 내용이 출력됩니다. 정상적으로 DataFrame이 출력되긴 했죠. 그러나 가독성이 그닥 좋아보이진 않습니다. 지금 예시로 사용된 DataFrame은 굉장히 간단해서 이것만으..

Slack API 등록, Slack Webhook 등록, Slack App 생성, Slack App 설치 Link slack_sdk library와 slack token을 사용해서 slack bot으로 message 보내기 Link Slack에 message를 보낼 땐 Slack token이 아닌 Slack webhook url을 사용할 수도 있습니다. 이 방법을 사용하면 token은 필요없습니다. webhook url은 Slack API 관리페이지에서 왼쪽 navigation bar에서 Incomin Webhooks를 이용하면 각 채널별로 Webhook URL을 찾을 수 있습니다. from slack_sdk import WebhookClient from slack_sdk.errors import Sla..