- dictionary ์์ key๋ก value๋ฅผ ์ถ๋ ฅํ๋ ค๋ฉด key ๊ฐ์ด unique ํด์ผํ๋ค.
- alban : 2.81 ์ผ๋ก ๋ง์ง๋ง์ ์ถ๊ฐํด์ค ๊ฐ์ ์ถ๋ ฅํ์ ๋ ๋์ค์ง ์๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค. ( ์ด ๊ฐ์ dictionary ์ ๋ณด๊ด๋๋ค.)

- key ๊ฐ์ unique ํด์ผํ๋ฉฐ immutable(๋ถ๋ณ) ํด์ผํ๋ค. (์์ฑ๋ ํ์ ๋ณ๊ฒฝ ๋์ด์๋ ์๋๋ค.)
- str, bool, int ๋ชจ๋ ๋ถ๋ณํด์ผ ํ์ง๋ง ์ด๋ list๋ ์์ฑ๋ ํ์ ๋ณ๊ฒฝ ๋ ์ ์๋ค.
- ํ์ง๋ง ๋๋ฒ์งธ์ ๊ฐ์ด list๋ฅผ key๋ก ์ฌ์ฉํ๊ฒ ๋ ๊ฒฝ์ฐ์ error๊ฐ ๋ฐ์ํ๋ค.

- ์ด๋ world ๋ผ๋ dictionary์ sealand ๊ฐ์ด 0.000027์ธ๋ฐ 0.000028์ผ๋ก ํ๋ฒ ๋ ์ถ๊ฐํด์ค๋ค๋ฉด, ๊ฐ์ด ์ถ๊ฐ๊ฐ ๋๋๊ฒ์ด ์๋๋ผ ๋ฎ์ด์์์ง๊ฒ ๋๋ค.
- ๊ทธ๋ฆฌ๊ณ del์ ์ฌ์ฉํ์ฌ ์ง์ฐ๋ ค๊ณ ํ๋ค๋ฉด ๊ฐ์ด ํ๋๋ง ์ง์์ง๊ณ ํ๋๊ฐ ๋จ๊ฒ ๋๋๊ฒ์ด ์๋๋ผ sealand๋ผ๋ ๋ชจ๋ ๊ฐ์ด ์ญ์ ๋๋ค.


- List vs Dictionary
- [] ๋ก select, update, remove ํ๋ ๊ฒ์ ๋ชจ๋ ๋์ผํ๋ค.
- list ์ ๊ฐ์ sequence ํ๋ค. ๋ฐ๋ผ์ ์ซ์์ ๋ฒ์๋ก indexing ๋๋ค.
ํ์ง๋ง dictionary๋ ๋ถ๋ณ(immutable)ํ๋ ๊ณ ์ ํค(unique key)๋ก indexing ๋๋ค.
- ๊ทธ๋ ๋ค๋ฉด ์ด๋จ๋ list๋ฅผ ์ฌ์ฉํ๊ณ ์ด๋จ ๋ dictionary๋ฅผ ์ฌ์ฉํ๋๊ฐ ?
- ์์๊ฐ ์ค์ํ๊ณ ๋ฐ์ดํฐ์ ์ ์ฒด ํ์ ์งํฉ์ ์ฝ๊ฒ ์ ํํ๊ธฐ ์ํด์ list๊ฐ ์ข๋ค.
- ํ์ง๋ง ๋น ๋ฅด๊ณ ๊ณ ์ ํ ๊ฐ์ ์ฐพ์๋์๋ dictionary๊ฐ ์ข๋ค.

- ์ฐ์ต
- dictionary ์์ ์์ ์์ dictionary ์์ด ๋ ์๋ ๊ฒฝ์ฐ
๊ฐ์ ๊ตฌํด์ค๋ [][]๋๋ฒ์ ๋๊ดํธ๋ฅผ ์ฌ์ฉํ์ฌ value๋ฅผ ๊ตฌํ๋ค.
- sub-dictionary์ ๊ฐ์ ์ถ๊ฐํด์ค ๊ฒฝ์ฐ
data = { 'capital':'rome', 'population' : 59.83 } ์ผ๋ก data๋ก ๋จผ์ ๋ง๋ค์ด์ฃผ๊ณ
europe['italy'] = data ํด์ค์ผ ์๋์ ๊ฐ์ด ๋ง๋ค์ด ์ง๋ค.
'italy': {'capital': 'rome', 'population': 59.83}}

- ์ฌ๋ผ์ด๋ ์ถ์ฒ : Datacamp - Datascientist with python
https://campus.datacamp.com/courses/intermediate-python/dictionaries-pandas?ex=5
'๐ฉ๐ปโ๐ป DataScientist for Python > DataCamp' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| Transforming DataFrames 1 - DataFrames (0) | 2022.09.27 |
|---|---|
| Intermediate Python 6 - Pandas read csv file (0) | 2022.09.20 |
| Intermediate Python 4 - Dictionary (0) | 2022.09.20 |
| Intermediate Python 3 - Scatter plot option (0) | 2022.09.19 |
| Intermediate Python 2 - Matplotlib(Ticks) (1) | 2022.09.19 |