-
[pandas] pandas profiling on Google Colab (구글코랩에서 판다스 프로파일링 해보기)데이터분석 2022. 7. 14. 21:09
1. 판다스 프로파일링 설치하기
! pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip
2. 런타임 다시 실행
3. 라이브러리 import
import numpy as np import pandas as pd try: from pandas_profiling import ProfileReport except : print('reinstall pandas profiling') !pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip from pandas_profiling import ProfileReport
4. 프로파일링 하려는 데이터 import 하고 읽어오기
- 드라이브 마운트 없이 구글 드라이브 공유 링크로 데이터 import
## 구글 드라이브 공유 설정 public (링크가 있는 모든 사용자 접근)으로 변경하면 ## drive mount 없이 데이터 읽을 수 있음 data_url = 'https://drive.google.com/file/d/.../view?usp=sharing' data_url_parsing='https://drive.google.com/uc?id=' + data_url.split('/')[-2] data = pd.read_csv(data_url_parsing)
5. 프로파일 리포트 정의
profile = ProfileReport(data, title = 'detecting test dataset', html={'style':{'full_width':True}})
6-1. 프로파일 위젯으로 보기
profile.to_notebook_iframe()
6-2. 프로파일 html 로 다운로드 받기
- 드라이브 마운트 없이 구글 드라이브 공유 링크로 데이터 내보내기
- output_file에 '/content/원하는파일이름' 적어주면 됨
profile.to_file(output_file='/content/detecting_test.html')
output 파일 7. 결과 확인
- 변수별로 확인
Toggle details 클릭하면 아래와 같이 결과를 확인할 수 있음
토글 디테일 결과 - 인터랙션 : x,y 변경 하면서 확인 가능
profiling - interaction image - 상관관계
profiling correlation image - 결측치
profiliong na count image - 상단 , 하단 행 (head, tail)
profiling head,tail image '데이터분석' 카테고리의 다른 글
[pandas] read_csv 필요한 열만 읽기 usecols (0) 2022.10.13 [pandas] replace 로 값 한꺼번에 바꾸기 ( replace with dictionary, regex) (0) 2022.08.10 윈도우 python 가상환경에 kaggle api 설치 (0) 2022.07.15 [pandas] sort_values 이용해 열 기준 정렬 (0) 2021.02.16 구글 코랩에서 데이터 분석 (데이터분석 수업 복습 01) (0) 2021.02.16