본문 바로가기

반응형

Programming Language

(11)
[Python] pytimekr 패키지 https://pypi.org/project/pytimekr/ pytimekr PyTime fork for Korean pypi.org PyTime을 포크(fork)해서 대한민국의 공휴일을 추가한 패키지이다. 이 패키지를 이용해서 Python에서 한국 공휴일(holidays)를 출력할 수 있다. 설치 pip install pytimekr 간단 사용법 >>>from pytimekr import pytimekr >>> >>>chuseok = pytimekr.chuseok() # 추석 >>>print chuseok datetime.date(2015, 9, 27) >>> >>>pytimekr.red_days(chuseok) # 추석 연휴 [datetime.date(2015, 9, 26), datetime.dat..
[Python] selenium.common.exceptions.ElementClickInterceptedException Python selenium을 이용하여 웹 크롤링을 하면 다음 에러가 발생할 수 있다.에러 발생 코드next_btn = driver.find_element(By.XPATH, '//*[@id="btnNextPage"]')next_btn.click() # 작동 하지 않음selenium.common.exceptions.ElementClickInterceptedException 이 에러는 특정 HTML element를 클릭할 때 해당 element를 클릭할 수 없도록 JS 처리(버튼 클릭 비활성화)가 되어 있거나, selenium과 같은 장치로부터 요소 클릭이 차단된 경우에 발생할 수 있다. 즉 원하는 요소가 다른 요소에 의해 차단 되어 요소를 클릭할 수 없기 때문에 에러가 발생한 것이다. 해결 방법아래 코드..
[Python] ValueError: If using all scalar values, you must pass an index 에러 원인 코드)import pandas as pddict = { 'a': 1, 'b': 2, 'c': 3,}df = pd.DataFrame(dict) 결과)ValueError: If using all scalar values, you must pass an indexDictionary를 DataFrame으로 변환할 때 위의 에러가 발생했다.에러 원인은 모든 값(Value)이 스칼라이기 때문이다. 이 에러 해결 방법은 다음 4가지가 있다.# 1. index 값 지정dict = { 'a': 1, 'b': 2, 'c': 3,}df = pd.DataFrame(dict, index=[0])print(df)# a b c# 0 1 2 3# 2. dictionary의 키..
[Python] UUID로 고유 식별자 만들기 UUID란?uuid는 네트워크 상에서 중복되지 않는 고유한 식별자인 UUID(Universally Unique IDentifier)를 생성할 때 사용하는 모듈이다. uuid.uuid1(node=None, clock_seq=None)호스트 ID, sequence 번호 및 현재 시각으로 UUID를 생성한다. node가 주어지지 않으면, getnode()를 사용하여 하드웨어 주소를 얻는다. clock_seq가 주어지면 시퀀스 번호로 사용한다. 그렇지 않을 경우, 무작위 14bit 시퀀스 번호를 사용한다. uuid.uuid3(namespace, name)이름 공간 식별자(UUID) 및 이름(문자열)의 MD5 해시를 기반으로 UUID를 생성한다. uuid.uuid4()무작위 UUID를 생성한다. uuid.uuid..
[Python] pandas dataframe 행/열 count pandas dataframe의 행 또는 열의 수를 카운트하는 방법을 알아보자.  Referencehttps://stackoverflow.com/questions/15943769/how-do-i-get-the-row-count-of-a-pandas-dataframe
[Python] pymysql connection option pymysql.connections.Connection() class parameterclass pymysql.connections.Connection(*, user=None, password='', host=None,database=None, unix_socket=None, port=0, charset='', sql_mode=None,read_default_file=None, conv=None, use_unicode=True, client_flag=0,cursorclass=, init_command=None,connect_timeout=10, read_default_group=None, autocommit=False,local_infile=False, max_allowed_packet=16777216,..
[Python] Jinja template Jinja (template engine)Jinja wikipedia Jinja (template engine) - WikipediaFrom Wikipedia, the free encyclopedia Template engine for the Python programming language associated with the Flask framework Jinja is a web template engine for the Python programming language. It was created by Armin Ronacher and is licensed under a BSD Len.wikipedia.org Jinja는 Python용 웹 템플릿 엔진이다.Jinja는 Flask의 기본 템플릿 엔진이며..
[Python] datetime format python datetime 공식문서YYYYMMDD 형식으로 파라미터를 입력 받아서 sql 쿼리에 사용할 때 유용하게 사용하는 tip 이다.import datetimetarget_date_str = '20230418'target_date_formatted = f"{target_date_str[:4]}-{target_date_str[4:6]}-{target_date_str[6:8]}"print(target_date_formatted)target_dt_formatted = f"{target_date_formatted} 00:00:00"print(target_dt_formatted)target_date_formatted_utc = ( datetime.datetime.strptime(target_dt_fo..

반응형