Giter VIP home page Giter VIP logo

2019_analysis-of-jeju-tourist's Introduction

์ œ์ฃผ ์ž…๋„ ํ˜„ํ™ฉ DB ํ™” ๋ฐ ์‹œ๊ฐํ™”

2019.11.19 ์ถฉ๋ถ๋Œ€ํ•™๊ต ์ˆ˜ํ•™๊ณผ ๋ฐ•์ง€์ˆ˜

์ˆ˜์—…๋ช… : ๊ณ ๊ธ‰ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด

์ง€๋„๊ต์ˆ˜ : ์กฐ์™„์„ญ

๋ชฉ์ 

  • ๊ณต์‹œ์šฉ ์—‘์…€ ๋ฐ์ดํ„ฐ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœํ•˜์—ฌ ๋ถ„์„ ๋ฐ ์‹œ๊ฐํ™” ํ•˜๊ธฐ ์ข‹์€ ํ˜•ํƒœ๋กœ ๊ตฌ์„ฑ
  • ์ œ์ฃผ ๊ด€๊ด‘ ํŠน์ง•์„ ์กฐ์‚ฌํ•˜๊ณ , ํ–ฅํ›„ ๊ณ„ํš ์ˆ˜๋ฆฝ์— ๊ธฐ์—ฌ

๊ฐœ์š”

  • Excel์—์„œ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœํ•˜์—ฌ DB๋กœ ์ €์žฅํ•œ๋‹ค.
  • ์ €์žฅํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์— ๋”ฐ๋ผ plot์„ ์ถœ๋ ฅํ•œ๋‹ค
    • ํŒŒ์ด์ฐจํŠธ, ํžˆ์Šคํ† ๊ทธ๋žจ, ์„ ํ˜• plot๋“ฑ ๋‹ค์–‘ํ•œ ํ˜•ํƒœ๋กœ ์ œ๊ณต

์ƒ์„ธ ๋‚ด์šฉ

1. excel ์›๋ณธ ๋ฐ์ดํ„ฐ ํ™•์ธ

  • ์›”๋ณ„๋กœ ์‹œํŠธ๋กœ ๋‹ค๋ฅด๊ฒŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.
  • ์ „์ฒด์ ์ธ ํ๋ฆ„์„ ๋ณด๊ธฐ ์–ด๋ ค์šด ๊ตฌ์กฐ
  • ์—ฐ๋ณ„, ์›”๋ณ„ ๋ฐ์ดํ„ฐ๋ฅผ ํŒŒ์•…ํ•˜๊ธฐ ํž˜๋“ค๋‹ค.

image-20210619150955764

2. DB ์ €์žฅ

con = sqlite3.connect("testDB") # DB ์ƒ์„ฑ
cur = con.cursor() # DB ์—ฐ๊ฒฐ
cur.execute("create table jejutourist2(\ # ํ…Œ์ด๋ธ”, ์Šคํ‚ค๋งˆ ์ƒ์„ฑ
    ...
)

wb = xlrd.open_workbook('C:/data/jejuall.xls') # ์—‘์…€ ์—ด๊ธฐ

# ์—‘์…€ -> DB insert
i=0
while i < wb.nsheets:
    sh = wb.sheet_by_index(i)
    print(sh.name, sh.nrows, sh.ncols)
    cur.execute("insert into jejutourist2 values (?,?,?,?,?,?,\
                                           ?,?,?,?,?,\
                                           ?,?,?,?,?,\
                                           ?,?,?,?)", 
                (i+1,\
                 (((str(sh.cell(2,6))).split("'"))[1])[:4],\
                 (((str(sh.cell(0,0))).split())[1]).rstrip("์›”"),\
                 ...

3. ์˜ต์…˜ ์„ ํƒ

  • ์—ฐ๋„ ์„ ํƒ
  • ์—ฐ๊ฐ„ ๊ตญ๊ฐ€๋ณ„ ๊ด€๊ด‘๊ฐ ์ค‘ ์ตœ๋Œ€๊ฐ’ ์ถ”์ถœ
if a=='2016':
    for row in cur.execute("select year,max(sum(f_japan), sum(f_china), sum(f_hongkong), sum(f_taiwan), sum(f_singapore), sum(f_malasia), sum(f_usa)) as dum_of_d_group \
                            from jejutourist2\
                            where year=2016;"):

4. ์‹œ๊ฐํ™”

fig=plt.figure() # plot ์ดˆ๊ธฐ ์ƒ์„ฑ
a=fig.add_subplot(1,3,1) # subplot
cur.execute("select sum(f_japan), sum(f_china), sum(f_hongkong), sum(f_taiwan), sum(f_singapore), sum(f_malasia), sum(f_usa) as dum_of_d_group \
                            from jejutourist2\
                            where year=2016;")
rows = cur.fetchall() # ์œ„์—์„œ ์ถ”๊ฐ€ํ•œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
print(rows)
ratio = rows
labels = ['japan','china','hongkong','taiwan','singapore','malasia','usa']
plt.pie(ratio, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90)

5. ๊ฒฐ๊ณผ

  • 2016, 2017, 2018 ์—ฐ๋„๋ณ„ ๊ตญ๊ฐ€๋ณ„ ํŒŒ์ด์ฐจํŠธ

image-20210619152252457

  • 2016~2018 ํƒ€์ž…(๊ฐœ์ธ, ๊ทธ๋ฃน, ๋ ˆ์ €) ๋ณ„ ๊ด€๊ด‘๊ฐ ํ˜„ํ™ฉ

image-20210619152425518

  • (์ขŒ) ์›”๋ณ„, ํƒ€์ž…๋ณ„ ๊ด€๊ด‘๊ฐ ๋ˆ„์  (์šฐ) ์›”๋ณ„, ๊ตญ๊ฐ€๋ณ„ ๊ด€๊ด‘๊ฐ ๋ˆ„์ 

image-20210619152519305

  • ์›”๋ณ„ ์ฃผ์š” ๊ตญ๊ฐ€ ๊ด€๊ด‘๊ฐ ์ˆ˜

image-20210619152621580

6. ๋ถ„์„

  • ์ค‘๊ตญ ๊ด€๊ด‘๊ฐ์ด 2017.04 ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๊ธ‰๊ฐํ–ˆ๋‹ค. ์ด๋Š” ๋‹น์‹œ ์‚ฌ๋“œ๋ฐฐ์น˜์˜ ์˜ํ–ฅ์œผ๋กœ ์ค‘๊ตญ์ธ ๊ด€๊ด‘๊ฐ์ด ๊ฐ์†Œํ•œ ๊ฒƒ์œผ๋กœ ํ•ด์„ํ•  ์ˆ˜ ์žˆ๋‹ค.

    image-20210619153823042

  • ๊ฐœ์ธ ๊ด€๊ด‘๊ฐ์ด ๊พธ์ค€ํžˆ ์ฆ๊ฐ€ํ•˜๊ณ  ์žˆ๋‹ค. 1์ธ ํ˜น์€ 2์ธ ๋“ฑ ์†Œ๊ทœ๋ชจ ๊ด€๊ด‘๊ฐ์ด ์ฆ๊ธธ ์ˆ˜ ์žˆ๋Š” ์—ฌํ–‰ ์ฝ”์Šค๋‚˜ ์‹๋‹น์„ ์ ๊ทน์ ์œผ๋กœ ํ™๋ณดํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ ๋œ๋‹ค.

  • ์˜คํžˆ๋ ค ํ•œ์—ฌ๋ฆ„ ์„ฑ์ˆ˜๊ธฐ๋ณด๋‹ค ๋ด„ ๊ฐ€์„, ์‹ฌ์ง€์–ด ๊ฒจ์šธ์— ๊ด€๊ด‘๊ฐ์ด ๋งŽ๋‹ค. ๊ณ„์ ˆ๋ณ„ ๊ด€๊ด‘ ์ฝ”์Šค๋ฅผ ๊ตฌ์„ฑํ•˜์—ฌ ๊ด€๋žŒ๊ฐ์˜ ๋‹ˆ์ฆˆ๋ฅผ ์ถฉ์กฑ ์‹œํ‚ค๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

๊ฒฐ๋ก  ๋ฐ ๋ฐฐ์šด์ 

  • ๋ฐ์ดํ„ฐ์˜ ํ˜•ํƒœ์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ์˜ ๊ฐ€์น˜๊ฐ€ ๋‹ฌ๋ผ์ง€๊ธฐ๋„ ํ•œ๋‹ค.
  • ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‹ค ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ DB ํ˜•ํƒœ๋กœ ์ €์žฅํ•˜๊ณ , ์ด๋ฅผ ๋ถ„์„ํ•˜๋ฉด ํ–ฅํ›„ ๊ด€๊ด‘ ์‚ฐ์—…์— ๊ธฐ์—ฌํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค.
  • xlrd ๋กœ ์—‘์…€ ํŒŒ์ผ์„ ์—ด๊ณ , ์…€์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.
  • sqlite3 ๋กœ sql๋ฌธ์„ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

2019_analysis-of-jeju-tourist's People

Contributors

parkjisu6239 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.