๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป Programming ๊ฐœ๋ฐœ/๐Ÿ Python

[ํŒŒ์ด์ฌ] ์˜ค๋Š˜์ฝ”๋“œ ๋ฐ์ดํ„ฐ ํฌ๋กค๋ง ์„ธ๋ฏธ๋‚˜ ํ›„๊ธฐ

by kimdee 2021. 6. 25.
๋ฐ˜์‘ํ˜•

* ์ด ๊ธ€์€ 2019๋…„ 10์›” 21์ผ์— ์ฐธ์—ฌํ•œ ์˜ค๋Š˜์ฝ”๋“œ(https://www.youtube.com/results?search_query=todaycode)๋‹˜์˜

์„ธ๋ฏธ๋‚˜ ๋‚ด์šฉ์„ ๊ฐ„๋žตํ•˜๊ฒŒ ์ •๋ฆฌํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. 

 

 

 

 

1. ์˜ค๋Š˜์ฝ”๋“œ ํ•ธ์ฆˆ์˜จ ์„ธ๋ฏธ๋‚˜ ๊นƒํ—ˆ๋ธŒ ๋งํฌ

 

https://github.com/corazzon/todaycode-hands-on

 

 

2. ๋ฌด๋ฃŒ๋กœ ๊ณต๋ถ€ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ์ดˆ ํŒŒ์ด์ฌ ์˜จ๋ผ์ธ ์ž๋ฃŒ

 

ํŒŒ์ด์ฌ ๋„ํ๋จผํŠธ

https://docs.python.org/3/tutorial/index.html

 

์ ํ”„ํˆฌ ํŒŒ์ด์ฌ ์œ„ํ‚ค๋…์Šค

https://wikidocs.net/book/1

 

์ฝ”๋”ฉ๋„์žฅ ํŒŒ์ด์ฌ

https://dojang.io/course/view.php?id=7 

 

ํŒŒ์ด์ฌ ๋ฌธ๋ฒ•์„ ์–ด๋Š์ •๋„ ๊ณต๋ถ€ํ–ˆ๋‹ค๋ฉด,

์ดํ›„์—๋Š” ์ฒ˜์Œ๋ถ€ํ„ฐ ๋๊นŒ์ง€ ๋‹ค ์‹ค์Šตํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ

๊ทธ๋•Œ๊ทธ๋•Œ ํ•„์š”ํ•œ ๋‚ด์šฉ์„ ์ฐพ์•„๋ณด๋Š” ๊ฒƒ์„ ์ถ”์ฒœ. 

 

3. ํŒŒ์ด์ฌ์œผ๋กœ ์ปค๋ฆฌ์–ด๋ฅผ ์‹œ์ž‘ํ•˜๋ ค๋ฉด

 

1) ADSP(๋ฐ์ดํ„ฐ๋ถ„์„์ค€์ „๋ฌธ๊ฐ€)์™€ ๊ฐ™์€ ์ž๊ฒฉ์ฆ ๋ณด๋‹ค๋Š” ํฌํŠธํด๋ฆฌ์˜ค์— ์‹ ๊ฒฝ์„ ์“ฐ์ž

2) ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ github์— ์˜ฌ๋ฆฌ์ž 

3) ํฌํŠธํด๋ฆฌ์˜ค๋Š” ์–ด๋–ค๊ฑธ ํ•ด์•ผ? ๊ทธ๋‚ ๊ทธ๋‚  ๊ณต๋ถ€ํ•œ ๊ฑธ ํฌํŠธํด๋ฆฌ์˜ค๋กœ. 

 

์˜ค๋Š˜์ฝ”๋“œ๋‹˜๋„ ๋ณธ์ธ์ด ๊ณต๋ถ€ํ•œ ๊ฒƒ๋“ค์„ ์ •๋ฆฌํ•˜์—ฌ ์˜ค๋Š˜์ฝ”๋“œ ์œ ํˆฌํŠธ ๊ณ„์ •์— ์˜ฌ๋ฆฌ์…จ๋Š”๋ฐ, 

๊ทธ๊ฑธ ํ†ตํ•ด์„œ ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ๊ด€์‹ฌ์„ ๊ฐ€์ ธ์ฃผ์‹œ๊ณ  ๋‹น์‹œ ๋‹ค๋‹ˆ์‹œ๋˜ ํšŒ์‚ฌ๋„ ์œ ํŠœ๋ธŒ๋ฅผ ๋ณด๊ณ  ์—ฐ๋ฝ์ฃผ์‹  ๊ฑฐ๋ผ๊ณ . 

 

 

 


ํŒŒ์ด์ฌ์˜ ๋‹ค์–‘ํ•œ ๊ทธ๋ž˜ํ”„๋“ค๊ณผ ๊ทธ ์“ฐ์ž„์ƒˆ

 

https://colab.research.google.com/notebooks/charts.ipynb

 

 

๋ผ์ธ์ฐจํŠธ  Line Graph

์„  ๊ทธ๋ž˜ํ”„์˜ ๊ฒฝ์šฐ ์„œ๋ฒ„ ํŠธ๋ž˜ํ”ฝ ์–‘ ๋“ฑ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ์šฉ๋„๋กœ ์“ฐ์ž„

 

๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ Bar Plot

์ˆซ์ž ๋ฐ์ดํ„ฐ๋ฅผ ์‹œ๊ฐํ™”ํ•ด์„œ ๋ณด๊ณ  ์‹ถ์„ ๋•Œ

 

 

ํžˆ์Šคํ† ๊ทธ๋žจ Histogram ๊ณผ ๋ˆ„์  ํžˆ์Šคํ† ๊ทธ๋žจ Cumulative Histogram

 

๋„์ˆ˜๋ถ„ํฌํ‘œ๋ฅผ ์‹œ๊ฐํ™”ํ•œ ๊ฒƒ์ด ํžˆ์Šคํ† ๊ทธ๋žจ, ๋ˆ„์ ํ™”ํ•˜์—ฌ ๋ณด๋Š” ๊ฒƒ์ด ๋ˆ„์  ํžˆ์Šคํ† ๊ทธ๋žจ 

 

 

์‚ฐ์ ๋ถ„ํฌ๋„(์‚ฐ์ ๋„) Scattor Plot

 

x์ถ•๊ณผ y์ถ•์ด ๋‹ค ์ˆซ์ž์ผ ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. 

 

Area Plot (Area Graph)

 

Image by Katemangostar from freepick

 

๊บพ์€ ์„  ๊ทธ๋ž˜ํ”„์˜, ์„  ์•„๋ž˜ ์˜์—ญ์ด ์ƒ‰์ด๋‚˜ ์งˆ๊ฐ์œผ๋กœ ์ฑ„์›Œ์ ธ ์žˆ๋Š” ๊ฒƒ์„ Area Graph(๋˜๋Š” Area Plot)์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

matplotlib์˜ ๋น„ํŠธ์œˆ์•ค ์•ŒํŒŒ๋กœ fill_between ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. 

 

 

https://matplotlib.org/3.3.4/gallery/recipes/fill_between_alpha.html#:~:text=The%20fill_between%20function%20generates%20a,curve%20over%20some%20threshold%20value.

 

Fill Between and Alpha — Matplotlib 3.3.4 documentation

Note Click here to download the full example code Fill Between and Alpha The fill_between function generates a shaded region between a min and max boundary that is useful for illustrating ranges. It has a very handy where argument to combine filling with l

matplotlib.org

 

ํŒŒ์ด์ฐจํŠธ Pie Chart

ํŒŒ์ด๋ชจ์–‘์˜ ๊ทธ๋ž˜ํ”„. 

matplotlib์—๋Š” ํŒŒ์ด์ฐจํŠธ๊ฐ€ ์žˆ์ง€๋งŒ, Seaborn์ด๋‚˜ GGplot ์€ ์—†์Œ 

 

 

3D ๊ทธ๋ž˜ํ”„ 3D Bar Chart (3D Plot)

 

3d plot์€ ์‹œ๊ฐํ™”๋ฅผ ํ•  ๋•Œ ์‚ฌ์šฉ์„ ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•จ.

๋ณด๋Š” ๊ฐ๋„์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ๊ฐ€ ์ผ๊ด€๋˜์–ด ๋ณด์ด์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์—

 

 

Matplotlib์˜ 3D wireframe plot ์ด ์˜ˆ์จ. 

https://matplotlib.org/stable/gallery/mplot3d/wire3d.html

 

 

๊ทธ์™ธ ์„ค๋ช…

Seaborn ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” matplotlib์„ ํ™œ์šฉํ•˜๊ธฐ ์‰ฝ๊ฒŒ ๋งตํ•‘ํ•ด๋†“์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

http://seaborn.pydata.org/

 

์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒํ•œ ์‹œ๊ฐํ™”๋ฅผ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด Bokeh๋‚˜ Plotly๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœ

 

Bokeh : https://bokeh.org/

Bokeh ํ™ˆํŽ˜์ด์ง€ ๋ฉ”์ธ

 

Plotly : https://plotly.com/python/

 

Plotly ํ™ˆํŽ˜์ด์ง€ ๋ฉ”์ธ

 

 


 

๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ๊ณผ์ •

 

๊ฒฐ์ธก์น˜ (NA๊ฐ’)

https://m.blog.naver.com/tjdudwo93/220976082118

 

 

df_store.info()
#๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์— ๋Œ€ํ•œ ์š”์•ฝ์„ ๋ณด์—ฌ์คŒ 

df_store.isnull()
df_store.isnull().sum() #๋”ํ•˜๋ฉด ๊ฒฐ์ธก์น˜๊ฐ€ ๋ช‡๊ฐœ ์žˆ๋Š”์ง€ ๋ณด์—ฌ์คŒ 

 

.info() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์— ๋Œ€ํ•œ ์šฉ์•ฝ์„ ๋ณด์—ฌ์ฃผ๋Š”๋ฐ, 

๊ฐฏ์ˆ˜๊ฐ€ ๋‹ค๋ฅธ ๊ฑด ๊ฒฐ์ธก์น˜๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. 

 

๊ฒฐ์ธก์น˜๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์œผ๋ฉด ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ค˜์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— 

์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ๋“ค์€ ์ œ๊ฑฐํ•œ๋‹ค (์ปฌ๋Ÿผ๋“ฑ๋“ฑ) 

 

df_store[drop_columns].samples()
df_store = df_store.drop(drop_columns,axis=1)


df_store[["์ƒ๊ถŒ์—…์ข…๋Œ€๋ถ„๋ฅ˜๋ช…","์ƒ๊ถŒ์—…์ข…์†Œ๋ถ„๋ฅ˜๋ช…"]]
๋‘๊ฐœ์ด์ƒ์˜ ์ปฌ๋Ÿผ์€ ๋ฆฌ์ŠคํŠธํ˜•ํƒœ๋กœ ๊ฐ€์ ธ์˜ด 


df_store=df_store[df_columns].copy()
df_store

copy() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณต์‚ฌ๋ฅผ ํ•˜์ง€์•Š๊ณ 

์ด์šฉํ•˜๋ฉด ๋‚˜์ค‘์— ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๊ฒฝ๊ณ ๋ฉ”์‹œ์ง€๊ฐ€ ๋œจ๊ธฐ ๋•Œ๋ฌธ์— ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ๊ฐ’์„ ๋ณต์‚ฌํ•˜์—ฌ ์‚ฌ์šฉํ•œ๋‹ค.

 

 


ํ•ธ์ฆˆ์˜จ ์ฝ”๋“œ

https://colab.research.google.com/github/corazzon/todaycode-hands-on/blob/master/coffee-store-eda.ipynb

 

coffee-store-eda.ipynb

Run, share, and edit Python notebooks

colab.research.google.com

 

์ƒ๊ฐ€์—…์†Œ ์ •๋ณด ๊ณต๊ณต๋ฐ์ดํ„ฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ์Šคํƒ€๋ฒ…์Šค์™€ ์ด๋””์•ผ์˜ ์œ„๋„, ๊ฒฝ๋„๋ฅผ ๋ฐ›์•„์„œ ์‚ฐ์ ๋„ Scattor Plot ์œผ๋กœ ๋‚˜ํƒ€๋‚ด๊ธฐ

 

 

 


๊ณต๊ณต ๋ฐ์ดํ„ฐ ๋ฐ ํฌ๋กค๋ง ๊ด€๋ จ ๋‚ด์šฉ

 

url/robots.txt

robots.txt๋ฅผ ํ†ตํ•ด ํฌ๋กค๋ง์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์—†๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ์Œ

 

robots.txt๊ฐ€ ๋ฌด์—‡์ด๋ƒ๋ฉด ๊ฒ€์ƒ‰์—”์ง„์ด ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š”์ง€ ์—†๋Š”์ง€๊ฐ€ ๋ช…์‹œ๋˜์–ด ์žˆ๋Š” ๋ฌธ์„œ.

๋„ค์ด๋ฒ„ ์ •์ฑ…์€ ๋‹ค this allow๋ผ์„œ ํฌ๋กค๋ง์€ ํž˜๋“ค๊ณ 

๋„ค์ด๋ฒ„ API ์ œ๊ณต๋˜์–ด ์žˆ์–ด์„œ ๊ทธ๊ฑธ ์จ์•ผํ•จ. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ํฌ๋กค๋ง์œผ๋กœ ์ €์ž‘๊ถŒ ์นจํ•ด๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.  

 

์šฐ๋ฆฌ๋‚˜๋ผ์˜ ์ €์ž‘๊ถŒ์€ FTA๋ฅผ ๋”ฐ๋ฅด๊ธฐ ๋•Œ๋ฌธ์—

๋ฏธ๊ตญ์˜ ์‚ฌ๋ก€๋ฅผ ๋”ฐ๋ฅธ๋‹ค.

 

๊ณต๊ณต๋ฐ์ดํ„ฐ์™€ ์ด๋ฅผ ํ™œ์šฉํ•œ ์ž๋ฃŒ๋“ค

 

1. ๊ณต๊ณต ๋ฐ์ดํ„ฐ ํฌํ„ธ

https://www.data.go.kr/index.do

 

 

2. ์บ๊ธ€ 

https://www.kaggle.com/

๋จธ์‹ ๋Ÿฌ๋‹, ๋ฐ์ดํ„ฐ ์‚ฌ์ด์–ธ์Šค ์ปค๋ฎค๋‹ˆํ‹ฐ 

๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ๋ถ„์„ ์ปดํผํ‹ฐ์…˜์ด ์—ด๋ฆฌ๋Š” ๊ณณ. 

 

 

3. ํ•œ๊ฒฝ ๋‰ด์Šค๋ž˜๋น— 

http://newslabit.hankyung.com/

http://newslabit.hankyung.com/article/201702229336G

 

[#์„œ์šธ์ปคํ”ผ๋งต] โ‘ฆ์ด๋””์•ผ : ์„œ์šธ 9๋Œ€ ์นดํŽ˜ ์ง€๋„

๋‰ด์Šค๋ž˜๋น— ๋ฐ์ดํ„ฐ์ €๋„๋ฆฌ์ฆ˜ ํŠน์ง‘ ์‹œ๋ฆฌ์ฆˆ #์„œ์šธ์ปคํ”ผ๋งต ์ƒ์„ธ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต๊ฐœํ•ฉ๋‹ˆ๋‹ค. ๋‰ด์Šค๋ž˜๋น—์€ 23์ผ [#์„œ์šธ์ปคํ”ผ๋งต] ์ปคํ”ผ๊ณตํ™”๊ตญ์˜ ์ฆ๊ฑฐ…์นดํŽ˜ ์  ์ฐ์œผ๋ฉด ์ง€๋„๊ฐ€ ๋œ๋‹ค ์—์„œ ์ตœ๊ทผ 15๋…„์น˜ ์„œ์šธ ์นดํŽ˜ ์ •๋ณด

newslabit.hankyung.com

ํ•œ๊ฒฝ์—์„œ ๊ณต๊ณต๋ฐ์ดํ„ฐ๋ฅผ ์ด์šฉํ•ด์„œ ๋งŒ๋“  ์ž๋ฃŒ๋“ค์ด ๋งŽ๋‹ค. 

์ด๊ฑธ ํ†ตํ•ด์„œ ๋ฆฌ๋ฒ„์Šค ์—”์ง€๋‹ˆ์–ด๋ง์„ ํ•ด๋ณด๊ณ  ๊ณต๋ถ€๊ฐ€ ๊ฐ€๋Šฅ

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€