설치
pip install klib
pip install pandas
pip install seaborn
import warnings
# hide warnings
warnings.filterwarnings("ignore")
import klib
import pandas as pd
import seaborn as sns
df = sns.load_dataset("titanic")
df.head()

# 결측치에 대한 프로파일링 플롯
klib.missingval_plot(df)

# 양의 상관관계 플롯
klib.corr_plot(df, split='pos')
# 음의 상관관계 플롯
klib.corr_plot(df, split='neg')


# default representation of correlations with the feature column
klib.corr_plot(df, target='age') # age를 기준으로한 다른 피쳐들과의 상관계수를 나타낸 그래프

klib.corr_plot(df, target='fare') # fare를 기준으로한 다른 피쳐들과의 상관계수를 나타낸 그래프

# default representation of a distribution plot, other settings include fill_range, histogram, ...
klib.dist_plot(df) # 히스토그램 그리기

df_cleaned = klib.data_cleaning(df) # 데이터 클렌징
↳ df_cleaned 결과
Shape of cleaned data: (784, 15) - Remaining NAs: 692
Dropped rows: 107
of which 107 duplicates. (Rows (first 150 shown): [47, 76, 77, 87, 95, 101, 121, 133, 173, 196, 198, 201, 213, 223, 241, 260, 274, 295, 300, 304, 313, 320, 324, 335, 343, 354, 355, 358, 359, 364, 368, 384, 409, 410, 413, 418, 420, 425, 428, 431, 454, 459, 464, 466, 470, 476, 481, 485, 488, 490, 494, 500, 511, 521, 522, 526, 531, 560, 563, 564, 568, 573, 588, 589, 598, 601, 612, 613, 614, 635, 636, 640, 641, 644, 646, 650, 656, 666, 674, 692, 696, 709, 732, 733, 734, 738, 739, 757, 758, 760, 773, 790, 792, 800, 808, 832, 837, 838, 844, 846, 859, 863, 870, 877, 878, 884, 886])
Dropped columns: 0
of which 0 single valued. Columns: []
Dropped missing values: 177
Reduced memory by at least: 0.06 MB (-75.0%)
ydata-profiling 패키지 및 ipywidgets 설치하기
pip install ydata-profiling ipywidgets
필요한 패키지 import하기
import numpy as np
import pandas as pd
from ydata_profiling import ProfileReport
테스트 데이터 생성하기
df = pd.DataFrame(np.random.rand(100, 5), columns=["a", "b", "c", "d", "e"])
print(df.head())
↳ 테스트 데이터 생성 결과
a b c d e
0 0.995817 0.268284 0.563712 0.569891 0.489493
1 0.054562 0.586358 0.311612 0.794190 0.076927
2 0.801426 0.570937 0.747227 0.812121 0.881083
3 0.032467 0.155426 0.434115 0.641922 0.912143
4 0.498620 0.106867 0.099020 0.988647 0.054433
프로파일링 리포트 생성
profile = ProfileReport(df, title="Ydata Profiling Report")
#profile.to_widgets() # jupyter notebook에서 위젯으로 보기
profile.to_notebook_iframe() # HTML 보고서와 유사한 방식으로 셀에 직접 포함
profile.to_file("my_profiling_report.html") # HTML로 별도 저장
↳ 리포트 생성 결과
하..진짜 주피터노트북에서 자꾸 에러나서 아래부터는 colab으로 함 ㅠㅠ


import seaborn as sns
import pandas as pd
# Seborn 데이터 세트 로드
df_titanic = sns.load_dataset('titanic')
df_titanic.head()
↳ 결과

위의 titanic 데이터에 대한 프로파일링 리포트 생성하기
# titanic 데이터세트는 시간이 오래 걸려 최소수준의 분석만 실행
profile = ProfileReport(df_titanic, title = "Titanic 데이터에 대한 프로파일링 보고서", minimal=True)
profile.to_notebook_iframe()
profile.to_file("titanic_profiling_report.html") # HTML로 별도 저장
↳ 결과


import pandas as pd
movie_df = pd.read_csv('ko_test_label.csv', sep = ',')
#print(movie_df.info())
#print(movie_df.shape)
print(movie_df.head(5))
↳ 결과

위의 영화리뷰에 대한 프로파일링 리포트 생성하기
pf_movie = ProfileReport(movie_df, title="네이버 영화 리뷰 데이터에 대한 프로파일링 보고서")
# pf_movie.to_widgets() # jupyter notebook에서 위젯으로 보기
pf_movie.to_notebook_iframe()
pf_movie.to_file("review_profiling_report.html") # HTML로 별도 저장
↳ 결과


PyGWalker 설치하기
pip install "pygwalker[notebook]" --pre
필요한 패키지 import하기
import pandas as pd
import pygwalker as pyg
Pandas 데이터프레임으로 PyGWalker 실행함
import seaborn as sns
# Seborn 데이터 세트 로드
df_titanic = sns.load_dataset('titanic')
gwalker = pyg.walk(df_titanic).display_on_jupyter()
↳ 결과


DataFrame을 polars로 변경하여 pygwalker 실행
import polars as pl
titanic_pl = pl.from_pandas(df_titanic)
gwalker = pyg.walk(titanic_pl).display_on_jupyter()
