본문 바로가기

기술스택을 쌓아보자/Python26

[python/리눅스]HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules _________________________________ ERROR collecting tests/test_settings.py __________________________________ import file mismatch: imported module 'test_settings' has this __file__ attribute: /home/hoseung2/cc/tests/test_settings.py which is not the same as the test file we want to collect: /home/hoseung2/test_release/cc/tests/test_settings.py HINT: remove __pycache__ / .pyc files and/or use a u.. 2022. 8. 12.
TypeError: descriptor '__init__' of 'super' object needs an argument 제목과 같은 에러가 나와서 호잇! 했는데, 해결방법은 쉽다! # 수정전 def __init__(self): super.__init__() # 수정전 def __init__(self): super().__init__() super를 선언하는 것을 잊지 마시길 ㅎㅎ 2022. 7. 29.
[조각pandas] ValueError: cannot index with vector containing NA / NaN values해결법: na옵션 사용하기 title_list[ title_list["title"].str.startswith( "a" )] # 문자열 시작단어로 검색시도 Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 3, in "a" File "/opt/conda/lib/python3.6/site-packages/pandas/core/frame.py", line 2133, in __getitem__ return self._getitem.. 2022. 7. 10.
[조각 pandas] nsmallest, nlargest, serise.quantile로 상위 및 하위 n 개 n% 값 가져오기(각각 행과 열에서 ) nsmallest(), nlargest() => 칼럼을 기준으로 상위 N개 열을 기준으로 상위 n 개의 값을 가져올 때 쓴다. 첫번째 인자는 가져오려는 개수, 두번째 인자는 기준이 되는 칼럼. df.nsmallest(3, 'population') population GDP alpha-2 Tuvalu 11300 38 TV Anguilla 11300 311 AI Iceland 337000 17036 IS 추가적으로 keep을 설정할 수 있는데, 만약 3등인 것이 여러개인 경우 처리 방법을 의미한다 first: 가장먼저나온 값을 3등으로처리 last: 가장 마지막 행을 3등으로 처리 all: 놓치는 것없이 모두 다 출력 Series.quantile() df[df.a < df.a.quantile(.95)] 이렇.. 2022. 6. 10.