Python/Jupyter notebook
-
#11Python/Jupyter notebook 2023. 2. 5. 21:15
!pip install konlpy Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ Collecting konlpy Downloading konlpy-0.6.0-py2.py3-none-any.whl (19.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.4/19.4 MB 36.0 MB/s eta 0:00:00 Requirement already satisfied: numpy>=1.6 in /usr/local/lib/python3.8/dist-packages (from konlpy) (1.21.6) Collecting JPype1>=0.7..
-
#10Python/Jupyter notebook 2023. 1. 16. 21:38
import seaborn as sns import matplotlib.pyplot as plt In [2]: sns.set_theme(style="whitegrid") # seaborn의 테마 중 하나인 whitegrid로 나옴 In [ ]: # sns.set() # seaborn의 기본 테마인 darkgrid로 나옴 In [3]: penguins = sns.load_dataset("penguins") In [4]: penguins Out[4]: speciesislandbill_length_mmbill_depth_mmflipper_length_mmbody_mass_gsex01234...339340341342343 Adelie Torgersen 39.1 18.7 181.0 3750.0 Male Adeli..
-
#9Python/Jupyter notebook 2023. 1. 16. 21:37
import pandas as pd from scipy import stats import numpy as np In [2]: df = pd.read_csv('./도로교통공단_사회교육_교육실적정보_20201231.csv', encoding='cp949') In [4]: df.head(2) Out[4]: 실적번호교육일자지부코드교육구분교육구분_1교육장소교육인원교육시작시간교육종료시간01 777624 2020-01-07 인천지부 3 기관/단체, 기업체 등 교통안전교육 171연대 162 10:00:00 12:00:00 777625 2020-01-07 인천지부 3 기관/단체, 기업체 등 교통안전교육 172연대 43 14:00:00 16:00:00 In [6]: pd.Timestamp('2022-04-20') Out..
-
#8-3Python/Jupyter notebook 2023. 1. 16. 21:36
데이터 이산화 In [1]: import pandas as pd In [7]: fta = pd.read_excel('./FTA무역통계_20230109000036.xls', header=4, index_col=1) C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py:226: UserWarning: Workbook contains no default style, apply openpyxl's default warn("Workbook contains no default style, apply openpyxl's default") FTA 데이터에서 수출건수, 수출금액, 수입건수, 수입금액, 무역수지가 각각 평균 이상인 FTA와 평균 ..
-
#8-2Python/Jupyter notebook 2023. 1. 16. 21:28
데이터 이산화 In [1]: import pandas as pd In [7]: fta = pd.read_excel('./FTA무역통계_20230109000036.xls', header=4, index_col=1) C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py:226: UserWarning: Workbook contains no default style, apply openpyxl's default warn("Workbook contains no default style, apply openpyxl's default") FTA 데이터에서 수출건수, 수출금액, 수입건수, 수입금액, 무역수지가 각각 평균 이상인 FTA와 평균 ..
-
#8-1Python/Jupyter notebook 2023. 1. 16. 21:26
test_feature_scaled = scaler.transform(test_feature) test_feature_reduced = pca.transform(test_feature_scaled) df_lda_component = pd.DataFrame(df_lda,columns=['lda_component']) df_lda_component['target'] = df.sex fig, axs = plt.subplots(figsize=(16,8) , ncols=2 , nrows=1) sns.distplot(df_pca_component.loc[df_pca_component['target'] == 1, 'pca_component'], hist=True, kde=False, color="blue", labe..
-
#7Python/Jupyter notebook 2023. 1. 16. 21:25
실습1 Age 항목의 결측치를 파악해 아래 분석을 모두 수행 결측치를 0으로 대체 (fillna 함수 이용 가능) 전체 값의 평균으로 대체 (mean 함수 이용 가능) 중앙값으로 대체 (median 함수 이용 가능) 각 분석간의 데이터 편차를 확인한다 (통계적 특성) 나이 정보를 확인한 뒤, 나이 정보를 표준화/정규화 작업을 모두 수행해 보자 시간이 남는 분들이 하시고, 모르는 분들은 설명 들어가면서 같이 합니다 요금 정보의 outliar를 확인하고, 해당 정보를 어떻게 처리할지 생각해보자 In [2]: import pandas as pd In [4]: df = pd.read_csv('./test.csv') In [5]: df.head() Out[5]: PassengerIdPclassNameSexAgeS..
-
#6-2Python/Jupyter notebook 2023. 1. 16. 21:22
# 용례 1 class MyClass: i = 12345 def f(self): return 'hello world' MyClass.f(1) Out[2]: 'hello world' In [ ]: In [3]: class Complex: def __init__(self, realpart, imagpart): self.r = realpart self.i = imagpart # 다른 함수 선언 가능. 선언할 경우, r과 i를 사용 가능 # 그리고, 아래 셀의 코드처럼 counter 변수를 만들 경우, counter도 사용 가능 In [4]: x = Complex(3.0,-4.5) In [6]: x.i Out[6]: -4.5 In [7]: x.counter = 1 In [8]: while x.counter < ..