728x90 Python17 TypeError: sub_process() takes 1 positional argument but 11 were given 멀티 프로세싱 관련, 초기 작업 중 발생한 error 코드는 아래와 같다. # 메인 프로세스 if __name__ == "__main__": print("[main] start") p = mp.Process(target=sub_process, args=("startcoding")) p.start() print("[main] end") error 수정 코드는 아래와 같다. # 메인 프로세스 if __name__ == "__main__": print("[main] start") p = mp.Process(target=sub_process, args=("startcoding",)) p.start() print("[main] end") 차이점은 mp.Process 내 args (튜플 형태) 설정 시 1개만 부여.. Python 2024. 1. 25. re.error: look-behind requires fixed-width pattern 아래는 정규표현식에서 '후방 탐색(look-behind)' 시도하다 발생한 error 코드이다. # 2. Substitution (교체) str3 = "010-2343-4444" result = re.sub("(? Python 2024. 1. 24. 파이썬 코딩 High Level vs. Low Level 파이썬으로 '로또 번호 추출기'라는 프로그램을 직접 코딩한 후 강의 강사가 직접 작성한 코드와 비교한 결과 느낀 점을 제목에 반영했다. 이 프로그램의 특징은 모두가 알다시피 다음과 같다. 1~45 숫자들 중에서 서로 다른 6개의 숫자 추출 코드 영역은 ①공통 영역과 ②Main 영역, 그리고 ③결과 확인 영역 순서의 총 3 영역으로 분류하는데 이 영역들 중 Main 영역에서 차이점이 드러난다. 일단, 차이가 없는 공통 영역과 결과 확인 영역은 다음과 같다. ※ 공통 영역 # 로또 번호 추출기 import random def get_random_number(): number = random.randint(1, 45) return number lotto_numbers = [] # 로또 번호를 저장할 리스트 ※.. Python 2023. 1. 18. 파이썬 코딩 스타일 아래 링크들을 참조해서 코딩하면 된다. PEP (Python Enhancement Proposals) 8 – Style Guide for Python Code PEP 8 – Style Guide for Python Code | peps.python.org PEP 8 – Style Guide for Python Code Author: Guido van Rossum , Barry Warsaw , Nick Coghlan Status: Active Type: Process Created: 05-Jul-2001 Post-History: 05-Jul-2001, 01-Aug-2013 Table of Contents This document gives coding conventions for the Python co .. Python 2023. 1. 17. [Jupyter Notebook] TypeError: 'method' object is not subscriptable 마주하게 된 오류 메시지이다. --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [53], line 1 ----> 1 sum_of_students_by_class = sum_of_students_by_class.drop['user_id'] 2 sum_of_students_by_class TypeError: 'method' object is not subscriptable 그리고 상기 오류를 유발한 코드 위치가 오류 메시지에 보면 1행이라고 나와 있다. 이에 대한 오류를 잡은 정상 코드는 다음과 같다. sum_of_students.. Python 2022. 12. 9. [Jupyter Notebook] UserWarning: Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from current font. matplotlib 사용 중 나타나는 경고 메시지를 제목으로 잡았는데, 제목 내 HANGUL이란 단어에서 유추 가능하듯이 한글이 깨지는 경우(==네모 '□'로 나타나는 경우) 발생하는 경고이다. 해당 경고를 없애기 위해 가열찬 구글링으로 찾아서 참고한 글은 아래의 글이다. Ubuntu에서 Matplotlib 한글 폰트 설정 Ubuntu에서 Matplotlib 한글 폰트 설정 | Hooni's Playground 안적어두니 매번 까먹는다. 방법만 알면 간단하지만, 방법을 조금이라도 까먹으면 바로 삽질을 하게된다. Ubuntu 환경에서 나눔 폰트를 사용한다는 가정하에 다음의 방법을 따르면 된다. 나눔 폰 hooni-playground.com 경고를 없애기 전, 일단 맞닥트린 전체 경고 메시지 중 하나는 다음.. Python 2022. 12. 7. [Jupyter Notebook] TypeError: barplot() got multiple values for argument 'data' 아래는 제목의 오류를 가져오게 한 코드와 오류 내용이다. #그래프 크기 설정 plt.figure(figsize = (14, 5)) # 바 그래프 그리기 (x축 = Age_cat, y축 = Survived) sns.barplot('Age_cat', 'Survived', data = titanic) # 그래프 나타내기 plt.show() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [37], line 5 2 plt.figure(figsize = (14, 5)) 4 # 바 그래프 그리기 (x축 = Age_cat, y축 = Sur.. Python 2022. 12. 6. [Jupyter Notebook] ValueError: Cannot set a DataFrame with multiple columns to the single column ma2 먼저 제목의 오류 발생하기 전 코드와 결과이다. from pandas_datareader import data as pdr import yfinance as yf yf.pdr_override() import numpy as np import pandas as pd import FinanceDataReader as fdr df = fdr.DataReader('005930', '2018') df = df[['Close']].copy() df['ma1'] = df.rolling(3).mean().shift(1) df 제목의 오류가 발생한 코드이다. 1 from pandas_datareader import data as pdr 2 3 import yfinance as yf 4 yf.pdr_override() 5.. Python 2022. 11. 28. [Jupyter Notebook] ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected. 오류 원문이다. ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected. 저 오류는 필요한 패키지를 설치하지 않아 발생하는 오류이다. 따라서 해당 패키지를 설치하면 오류는 사라진다. !pip install matplotlib 입력하여 설치 Python 2022. 11. 26. [Jupyter Notebook] ValueError: If using all scalar values, you must pass an index 오류 원문이다. ValueError: If using all scalar values, you must pass an index 제목의 오류를 유발한 코드는 아래와 같다. corp_code = df_listed[df_listed['corp_name'] == '카카오'].iloc[0,0] data = dart_fss.api.info.emp_sttus(corp_code, '2021', '11011') df = pd.DataFrame(data['list']) df = df[['corp_code', 'corp_name', 'sexdstn', 'jan_salary_am']] #df doc = { '기업명': df['corp_name'][0], '연봉(남)': df[df['sexdstn'] == '남'].iloc[.. Python 2022. 11. 26. [Jupyter Notebook] ValueError: Unable to parse string "-" at position 78 오류 원문이다. ValueError: Unable to parse string "-" at position 78 제목의 오류(ValueError: Unable to parse string "-" at position 78)를 불러온 구문은 아래와 같으며 행 번호로는 14번 행이다. 1 import numpy as np 2 3 corp_code = df_listed[df_listed['corp_name'] == '카카오'].iloc[0, 0] 4 data = dart_fss.api.info.hyslr_sttus(corp_code, '2021', '11011', api_key = None) 5 6 df = pd.DataFrame(data['list']) 7 df = df[['corp_name', 'nm', .. Python 2022. 11. 26. [Jupyter Notebook] AttributeError: module 'collections' has no attribute 'MutableMapping' 오류 원문이다. AttributeError: module 'collections' has no attribute 'MutableMapping' [Jupyter Notebook] ImportError: cannot import name 'MutableSet' from 'collections' (/usr/lib/python3.10/collections/__init__.py) 글 내용 적용하고 바로 맞닥트린 오류이다. 물론 코드는 동일하다. File ~/.local/lib/python3.10/site-packages/arelle/pyparsing/pyparsing_py3.py:627 624 def __dir__(self): 625 return dir(super(ParseResults,self)) + self... Python 2022. 11. 25. 이전 1 2 다음 💲 추천 글 반응형 SMALL