Programming Language/Python
-
셀 연산 속도 측정 (파이썬 시간 측정)Programming Language/Python 2022. 11. 24. 17:08
셀 하나 단위로 측정하는 방법 import timeit %%timeit 현재시간 : now = time.localtime() import time start = time.time() # 시작 시간 저장 // 작업 내용 // runtime = time.time() - start # 첫 번째 방법 걸린 시간 print(runtime) import timeit starTime = timeit.default_timer() ... code ... endTime = timeit.default_timer() runningTime = endTime - startTime
-
Python Pandas : shift (행 위치 옮기기)Programming Language/Python 2022. 11. 22. 11:51
Pandas의 shift method는 DataFrame이나 Series에 적용해서 행의 위치를 일정 칸수씩 이동시킵니다. 또한 특정 column만 조금씩 위치를 옮기는 것도 가능합니다. df.shift(1) : 아래로 한 칸 내림 df.shift(-1) : 위로 한 칸 올림 예시 : 성공의 경우 1 / 실패의 경우 0 으로 표시한 칼럼 "이전 시도에서 성공했는가?" 의 새로운 정보를 표시하고 싶을 때. shift(1) 이용해서 한칸씩 내려서 이전 정보 추가
-
11-20-일Programming Language/Python 2022. 11. 20. 22:03
pprint = pretty print Series.tolist( ) .to_dict( ) (list comprehension 으로 바꾸는 것보다 이게 더 접근성이 좋지 않나 + numpy쓰는) .readline( ) .readlines( ) 도 있음! 다만 CPU 터질 수 있으니 자제하는 편 chunksize 너무 쪼개도 좋지 않을 수 있다 http://acepor.github.io/2017/08/03/using-chunksize/ Using Chunksize in Pandas Yet another blog about NLP, machine learning and programming acepor.github.io pd.read_parquet( ) 아주 큰 데이터셋 ex)64GB,, 도 불러올 수 있음..
-
-
헷갈리기 쉬운 axis 매개변수 개념Programming Language/Python 2022. 10. 13. 18:41
https://fhaktj8-18.tistory.com/entry/%ED%8C%90%EB%8B%A4%EC%8A%A4-axis-%EB%A7%A4%EA%B0%9C%EB%B3%80%EC%88%98-%EA%B0%9C%EB%85%90-%EC%99%84%EB%B2%BD%EC%A0%95%EB%A6%AC 판다스 axis 매개변수 개념 완벽정리 판다스를 공부하면서 매우 헷갈렸던게 행과 열이었다. 데이터프레임은 2차원 형태의 데이터를 다루기 위한 자료형으로, 행과 열이라는 축을 기준으로 정렬되어 있다. 행(row / index)은 각각의 레 fhaktj8-18.tistory.com
-
[python] 파이썬 정규표현식 / re 모듈 사용법Programming Language/Python 2022. 10. 12. 22:55
더보기 - 정규 표현식 문법 - re 모듈 사용법 실습 : https://regexr.com/ RegExr: Learn, Build, & Test RegEx RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp). regexr.com https://velog.io/@hhhs101/Pandas-%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D-str.extractstr.contains [Pandas] 정규표현식 (str.extract, str.contains) 1. 정규표현식 특정한 규칙을 가진 문자열을 검색하거나 치환하기 위해 사용된다. 메타문자 (Meta characters..
-
[python] 파이썬 자주 나오는 문장 부호 정리Programming Language/Python 2022. 10. 9. 10:51
어떻게 읽는지 헷갈려서 말로 전달할 때 어려움을 겪을 때가 많았다. 기호 punctuation 읽는법(영어) 문장부호 읽는법(한글) . period ( or dot) 마침표 , comma 쉼표 : colon 콜론 ; semi-colon 세미콜론 () parentheses (or round brackets) 소괄호, 퍼렌서시스 {} braces (curly brackets) 중괄호 [] square brackets (or box brackets) 대괄호 " " double quotation marks 큰따옴표 ' ' single quotation marks 작은따옴표 ' apostrophe 아포스트로피(작은따옴표) ` backtick ( or grave) 백틱 - hyphen 하이픈, 붙임표 _ low d..