728x90 Jupyter notebook12 [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. [Jupyter Notebook] ImportError: cannot import name 'MutableSet' from 'collections' (/usr/lib/python3.10/collections/__init__.py) Open DART API 사용을 하려고 API Key 신청하고 Jupyter Notebook .ipynb 파일에서 !pip install dart-fss 명령으로 관련 패키지를 설치한 후 아래와 같이 코드를 작성하고 실행했더니 바로 오류를 뿜었다. 참고로 설치된 Python 버전은 3.10.6이다. import dart_fss as dart_fss import pandas as pd api_key = '35f464ee744a0ce5247ac14b25f277a8c5fa7d3a' dart_fss.set_api_key(api_key = api_key) corp_list = dart_fss.get_corp_list() corp_list.corps 그리고 오류 내용은 아래와 같다. File ~/.local/lib.. Python 2022. 11. 25. [Jupyter Notebook] FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. (후략) 제목과 같은 Warning 메시지를 확인한 코드는 아래와 같다. import pandas as pd data = { 'name' : ['영수','철수','영희','소희'], 'age' : [20,15,38,8] } df = pd.DataFrame(data) doc = { 'name':'세종', 'age':14, } df = df.append(doc,ignore_index=True) df 상기 코드로 발생한 Warning 메시지 원문은 아래와 같다. FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead. df = df.appe.. Python 2022. 11. 25. [Jupyter Notebook] SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.Try using .loc[row_indexer,col_indexer] = value instead (후략) 앞서 작성했던, [Jupyter Notebook] FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead. new_df = df[{'name', 'current_price'}] 글에 이어 작업하다 나타난 Warning 메시지이다. 일단 전체 Warning 메시지는 아래와 같다. SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveat.. Python 2022. 11. 24. [Jupyter Notebook] FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead. new_df = df[{'name', 'current_price'}] Pandas 모듈을 import pandas as pd 선언으로 불러온 후 앞선 작업으로 생성했던 DataFrame에서 new_df = df[{'name', 'current_price'}] 입력하고 확인하기 위해 new_df 입력 후 Crtl + Enter 실행하니 제목과 같은 Warning 메시지가 나타났다. FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead. new_df = df[{'name', 'current_price'}] 메시지를 보니 df[{'name', 'current_price'}] Syntax는 더 이상 유지보수 되지 않는다는 (deprec.. Python 2022. 11. 24. 이전 1 다음 💲 추천 글 반응형 SMALL