| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
- BloombergMarketConcepts
- github2FA
- numpy.bool
- wordembedding
- implicitData
- TensorflowDeveloperCertificate
- ExplicitData
- decimal error
- session-basedRecommendation
- Python
- gluonnlp
- MySQL
- VScodeNotResponding
- sshtunnel
- DIF_SR
- vscode
- str.replace
- jsonlines
- MatrixFactorization
- 텐서플로자격증
- pandas
- Colab
- 지도시각화
- Cast
- json
- Convert
- Visualization
- jsonl
- LatentFactorModel
- iterrows
- Today
- Total
목록Python (15)
garret
데이터 분석을 할 경우, 카테고리형 변수, 또는 string을 전처리할 경우가 종종 생긴다. 사실 이전까지는 얄팍하게 알고 사용해온 감이 없지 않아 있어서, 이번 기회에 파라미터를 어떤 걸 쓸 수 있는지 공부해 보았다. str.replace() 함수 정의 Series.str.replace(pat,rept, n=-1, case=None, flags=0, regex=False) Series나 index에서 패턴이나 regex(정규식)를 교체하는 함수 str.replace(), re.sub()와 동일한 기능 수행 아웃풋 Series 나 object의 인덱스 파라미터 구성 pat : 기존 str 이나 regex repl : 대체 str n : 시작에서 부터 대체하고자 하는 개수(int). 디폴트 -1(전체) c..
SVR(Support Vector Regressor) 모델에 대해 SHAP(SHapley Additive exPlanations)을 구하려다 발생한 에러. 사용한 SVR 모델은 다음과 같다. # SVR 모델 from sklearn.svm import SVR from sklearn.metrics import mean_squared_error sv_reg = SVR(kernel = "linear") sv_reg.fit(train_x,train_y) sv_pred = sv_reg.predict(test_x) 찾아보니 SVR은 tree기반 모델이 아니라서 TreeExplainer을 사용하면 안된다고한다. # shap value import shap # SVM은 Tree기반이 아니라서 TreeExplainer 사..
비어 있는 데이터 프레임에 컬럼들을 append를 하려다가 발생한 오류. 사용한 pandas 라이브러리 version은 2.0.2이다. >> import pandas as pd >> pd.__version__ '2.0.2' 찾아보니 pandas 1.5 버전까지는 append 속성이 있었으나, pandas 2.0부터 append 속성이 제거된 것으로 보인다. pandas 2.0 이상 버전을 사용하는 경우, append 대신 concat 함수를 이용해야 할 듯. Concat 함수로 오류 해결하기 1. 추가하려는 데이터를 DataFrame으로 만들고, 2. 앞서 만든 DataFrame과 concat import pandas as pd food_df = pd.DataFrame() data = {"NUM":"",..
conda에서 python 가상 환경 생성하는 법 정리 작업 환경 : Window, Anaconda3, VScode 윈도우에서 작업하는 관계로, Anaconda가 연결된 VScode의 터미널에서 작업을 진행했다. 1. 가상환경 생성 및 활성화 1.1 가상환경 생성 먼저, 원하는 가상환경이름과 파이썬 버전을 지정해서 환경 생성을 해주자. $ conda create -n python = # 예시 $ conda create -n testenv python=3.10 Proceed : y 선택 가상환경 리스트 확인 $ conda env list 새로운 가상환경 testenv가 생성된 것 확인 가능 1.2 가상환경 활성화(실행) 가상환경을 생성했으니, 이제 사용할 수 있게 활성화해준다. $ conda activat..
islice()와 slice() 모두 슬라이싱하는데 사용되는 함수다. islice()를 공부하다가 slice()의 차이점이 어떤건지 궁금해서 정리 slice() 정의 Return a slice object representing the set of indices specified by range(start, stop, step). The start and step arguments default to None. Slice objects have read-only data attributes start, stop, and step which merely return the argument values (or their default). They have no other explicit functionali..
알고리즘 공부하면서 알게 된 join() 함수. split() 과 비교하면서 공부하면서 좋을 거 같아 정리. split() 함수 string.split(separator, maxsplit) split() 함수는 string을 list로 분할해주는 함수. separator character를 기준으로 분할된다. separator의 디폴트 값은 공백(whitespace) maxsplit에는 분할할 개수 지정 split() 사용예시 txt = "mango$blueberry$kiwi$melon" x = txt.split('$',1) print(x) $ 기준으로 분할하고 1번만 분할하라는 뜻 1번만 분할되어 2개의 element로 쪼개진 걸 확인 할 수 있다. join() 함수 string.join(iterabl..
백준 알고리즘 문제를 풀면서 알게된 sys.stdout.write()함수. 출력함수인데 print() 비슷한 듯 다른 것 같아 차이점을 정리해보았다. sys.stdout 정의 used for the output of print() and expression statements and for the prompts of input(): sys.stdout.write()와 print의 차이 출력 형태 sys.stdout.write() 줄바꿈없이 이어서 출력 print() 줄바꿈하여 출력 sys.stdout.write 출력 예시 import sys for i in range(5): sys.stdout.write(f"{i}") ※ 주의사항 ※ sys.stdout.write는 string만 넣을 수 있다. str말..
데이터에서 원하는 DataFrame으로 만든 후 correlation 구하려다가 마주친 에러. chatgpt에게 해당 오류 관련해 물어보니 다음처럼 알려줬다. Pandas DataFrame에 Styler.apply 또는 .applymap을 사용하여 스타일을 적용하려고 할 때, DataFrame의 인덱스 또는 컬럼이 고유하지 않으면 위와 같은 KeyError가 발생합니다. 이는 Pandas가 스타일 적용 시 모호성을 초래할 수 있기 때문입니다. 이 오류를 해결하려면, 인덱스 또는 컬럼을 고유하게 만들거나 다른 방법을 사용하여 스타일을 적용해야 합니다. 가능한 해결책 중 하나는 Styler.apply를 사용하여 DataFrame을 입력으로 받아 스타일이 적용된 DataFrame을 반환하는 함수를 작성하는 것..