Data Science / Section 1 / Sprint 1 / 20.12.28
Warm up
코드스테이츠 AI 첫 날
1) 블로그에 나의 스토리를 남기자
2) TIL TIW 만들기
Today I learned
보다 더 중요한 Today I Wondered
3) 7시 이후 줌 켜놓고 '모각코'
Lecture
EDA 탐색적 데이터 분석
'데이터를 가공하기 전에 주어진 자료 자체만으로 해석, 의미를 알아내는 방법'
Github
Fork & PR
Close & Commit
repository : github에서 특정 파일을 저장하는 폴더 / repo
df = pd.read_csv(ktng_data_url)
df.head() #제목포함 첫 5줄 보여주기
column_headers = ['분기', '매출액', ....]
#행열에 맞게 제목 정의해주고
df = pd.read_csv(ktng_data_url, names = column_headers)
#names = 상단제목 정의
print(df.head())
df.head()
#같은 결과값 , 아래값이 조금더 이쁘다
EDA
Line Plot
HIstogram
Scatter Plot
Bar Plot ...
###Matplotlib 한글 깨짐 현상
import matplotlib.pyplot as plt
import matplotlib as mpl
# Windows
mpl.rc("font", family='Malgun Gothic')
# MacOS
mpl.rc("font", family='AppleGothic')
# 마이너스 사인 수정
mpl.rc('axes', unicode_minus=False)
Assignment
1) 데이터셋 설정하기
data_url = 'https://www.data.csv'
2)판다스 불러오기 (넘파이도 같이)
import pandas as pd
import numpy as np
@확장자에 따라 설정값 달리주기
df = pd.read_csv(data_url)
df = pd.read_excel(data_url) nittaku.tistory.com/258
15. pandas로 excel파일 읽고 / 쓰기
pandas_excel.py 불러올 엑셀파일 : mandoo_management.xlsx 저장된 엑셀파일 : result.xlsx 새로운 파이썬 파일을 만든다. 불러올 엑셀파일을 만들고, 해당 프로젝트(studying_pandas)에 mandoo_management.xlsx..
nittaku.tistory.com
df.head() #잘불러왔는지 확인해보자
#데이터파일에 시트가 여러개일때 설정안해주면 시트1만 불러온다
Read Excel with Python Pandas - Python Tutorial
Read Excel files (extensions:.xlsx, .xls) with Python Pandas. To read an excel file as a DataFrame, use the pandas read_excel() method. You can read the first sheet, specific sheets, multiple sheets or all sheets. Pandas converts this to the DataFrame stru
pythonbasics.org
df_sheet_name = pd.read_excel('sample.xlsx', sheet_name='sheet1')
df_sheet_name = pd.read_excel('sample.xlsx', sheet_name='sheet2')
3) 판다스 활용하기
데이터 중 결측치(값X) 찾고 , 대체하기
[Python pandas] 결측값 채우기, 결측값 대체하기, 결측값 처리 (filling missing value, imputation of missing valu
지난번 포스팅에서는 결측값 여부 확인, 결측값 개수 세기 등을 해보았습니다. 이번 포스팅에서는 결측값을 채우고 대체하는 다양한 방법들로서, - 결측값을 특정 값으로 채우기 (replace missi
rfriend.tistory.com
df00 = df0.fillna(0) #결측치를 '0'으로 채우기
행열 바꾸기
pandas-docs.github.io/pandas-docs-travis/reference/api/pandas.DataFrame.transpose.html
pandas.DataFrame.transpose — pandas 0.25.0.dev0+752.g49f33f0d documentation
Parameters: copy : bool, default False If True, the underlying data is copied. Otherwise (default), no copy is made if possible. *args, **kwargs Additional keywords have no effect but might be accepted for compatibility with numpy.
pandas-docs.github.io
df1_transposed = df1.T # or df1.transpose()
4) Plot 으로 도식화하기
인덱스값 고정해주기
행열을 바꾸고나면 가장 첫줄이 0,1,2,3,4,5,6 으로 설정되어 에러발생
index 값을 고정해서 설정해주자
df00_t = df00.set_index('주요재무정보').transpose()
stackoverflow.com/questions/38148877/how-to-remove-the-extra-row-or-column-after-transpose-in-pandas
How to remove the extra row (or column) after transpose() in Pandas
After using transpose on a dataframe there is always an extra row as a remainder from the initial dataframe's index for example: import pandas as pd df = pd.DataFrame({'fruit':['apple','banana'],'
stackoverflow.com
5)matplotlib 한글이 깨지는 현상 발생
Google Colaboratory
colab.research.google.com
시키는대로 했는데도 안된다 ㅠㅠ
(여기서 시간 엄청 잡아먹음)
구글링을 해보니 아예 '런타임을 다시 시작'해야 적용된다고 한다
구글 Colab에서 한글 문제 대응하기
Python의 matplotlib의 기본 폰트가 한글을 지원하지 않아서 한글 폰트로 설정을 해주어야 합니다. 아나콘다에서는 그렇게 한글을 지원하도록 설정만 하면 문제가 없습니다. 그런데 구글의 Colab에서
pinkwink.kr
석세스~!
도전 Assignment
1) csv 각각 출력 (python export csv)
df00_t.to_csv(r'data0.csv')
df11_t.to_csv(r'data1.csv')
datatofish.com/export-dataframe-to-csv/
How to Export Pandas DataFrame to a CSV File - Data to Fish
You can use the following template in Python in order to export your Pandas DataFrame to a CSV file: df.to_csv(r'Path where you want to store the exported CSV file\File Name.csv', index = False) And if you wish to include the index, then simply remove “,
datatofish.com
2) Pairplot , Seaborn
전체 데이터를 pairplot 기본값으로 출력하는건 의미없음
가독성떨어지고 시간도 오래걸림
원하는 정보를 기준으로 잡던지 , 특정값만을 추출해서 그때그때 확인하는게 더 효율적으로 보임
sns.pairplot(df00_t, x_vars=["매출액", "영업이익", "당기순이익"], y_vars=["자산총계", "부채총계", "자본총계"])
seaborn.pydata.org/generated/seaborn.pairplot.html?highlight=pairplot#seaborn.pairplot
seaborn.pairplot — seaborn 0.11.1 documentation
Dictionaries of keyword arguments. plot_kws are passed to the bivariate plotting function, diag_kws are passed to the univariate plotting function, and grid_kws are passed to the PairGrid constructor.
seaborn.pydata.org
teddylee777.github.io/visualization/seaborn-tutorial-1
Seaborn의 통계 차트 및 데이터 시각화 예제
Seaborn 활용한 데이터 시각화 그래프 예제와 방법에 대하여 알아보겠습니다.
teddylee777.github.io
3)str , int (+float)
a = '1234' str, 문자로 인식
b = 5678 int, 숫자로 인식
정수형 ( int)
부동소수점형 (float)
문자형(str)
파이썬 시작하기 03 타입(int, float, str)
이야기할 내용들 어떤 연산자는 어떤 값(상수의 타입)을 사용하냐에 따라 다르게 동작한다. 서로다른 타입값을 사용할때 어떻게 달라질까?? <사전 지식 > 먼저 상수의 기본적인 종류는 크게 세
numuduwer.tistory.com
'AI월드 > ⚙️AI BOOTCAMP_Section 1' 카테고리의 다른 글
Data Visulaize,plot,seaborn_Day4 (0) | 2021.01.03 |
---|---|
Data Manipulation,concat,merge,melt_Day3 (0) | 2020.12.30 |
25 pandas tricks_Day3(2) (0) | 2020.12.30 |
Feature Engineering,형변환_Day2(2) (0) | 2020.12.30 |
Feature Engineering,데이터전처리,_Day2 (0) | 2020.12.29 |
댓글