๐Ÿ“„ Kedro - ๋‚ด ๋ฐ์ดํ„ฐ๋Š” ํ…Œ์ด๋ธ”์ด ์•„๋‹™๋‹ˆ๋‹ค

3633 ๋‹จ์–ด kedropythondata
Python ๋ฐ์ดํ„ฐ ๊ณผํ•™/์—”์ง€๋‹ˆ์–ด๋ง์—์„œ ๋Œ€๋ถ€๋ถ„์˜ ๋ฐ์ดํ„ฐ๋Š” ์ผ์ข…์˜ ํ…Œ์ด๋ธ” ํ˜•์‹์ด๋ฉฐ ์ผ๋ฐ˜์ ์œผ๋กœ pandas, spark ๋˜๋Š” dask์™€ ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ DataFrame์ž…๋‹ˆ๋‹ค.

DataFrames๋Š” ๋Œ€๋ถ€๋ถ„์˜ ํŒŒ์ดํ”„๋ผ์ธ์˜ ํ•ต์‹ฌ์ž…๋‹ˆ๋‹ค.



์ด๋Ÿฌํ•œ ๋ฐ์ดํ„ฐ ์ปจํ…Œ์ด๋„ˆ์—๋Š” ํ…Œ์ด๋ธ”๊ณผ ๊ฐ™์€ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ์กฐ์ž‘ํ•˜๋Š” ํŽธ๋ฆฌํ•œ ๋ฐฉ๋ฒ•์ด ๋งŽ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋•Œ๋•Œ๋กœ ์šฐ๋ฆฌ๋Š” ๋‹ค๋ฅธ ๋ฐ์ดํ„ฐ ์œ ํ˜•, ์ฆ‰ ๋ฐ”๋‹๋ผ๋ฅผ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค.
๋ชฉ๋ก ๋ฐ ์‚ฌ์ „๊ณผ ๊ฐ™์€ ์œ ํ˜• ๋˜๋Š” numpy ๋ฐ์ดํ„ฐ ์œ ํ˜•.




unfamiliar with kedro, check out this post



๋•Œ๋•Œ๋กœ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋Š” ํ…Œ์ด๋ธ”์ด ์•„๋‹™๋‹ˆ๋‹ค.



๋ฐ์ดํ„ฐ๊ฐ€ DataFrame์— ์ž˜ ๋งž์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์šด ์ข‹๊ฒŒ๋„ Kedro๋Š” ์ฆ‰์‹œ ํ”ผํด์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. Pickle์€ ํŒŒ์ด์ฌ์„ ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
๊ฐ์ฒด๋ฅผ ๋””์Šคํฌ์—. ์ถœ์ฒ˜๋ฅผ ์•Œ ์ˆ˜ ์—†๋Š” ํ”ผํด ํŒŒ์ผ์€ ์•…์„ฑ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ์•ˆ์ „ํ•˜์ง€ ์•Š์€ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋ฉ๋‹ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ
์ž์‹ ์˜ ํ”ผํด ํŒŒ์ผ์„ ์ฝ๊ณ  ์“ฐ์‹ญ์‹œ์˜ค. ๊ทธ๋“ค์€ ๊ณ ๋ คํ•ด์•ผ ํ•  ์ข‹์€ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค.

See more about pickle from python.org.


ํ”ผํด ๋ถ„๋ฅ˜



์ผ๋ถ€ ์ž๋™์ฐจ๋ฅผ ์„ค๋ช…ํ•˜๋Š” ์‚ฌ์ „์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

{
  'truck-012-abc': {
    'type': 'truck'
    'sales': [12, 2, 3, 4, 8]
    'weight': 9024,
    'accesories': ['leather', 'audio-1']
}


์นดํƒˆ๋กœ๊ทธ์—์„œ ์œ ํ˜•์„ pickle.PickleDataSet๋กœ ์„ค์ •ํ•˜๊ณ  filepath๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

cars:
  filepath: data/cars.pkl
  type: pickle.PickleDataSet


This filepath does not have to be on the local filesystem it can be on the cloud thanks to how kedro utilizes fsspec for each of its datasets.



๋ฐ์ดํ„ฐ์„ธํŠธ ๋กœ๋“œ


MemoryDataSet๋กœ ๋‘๋Š” ๊ฒƒ๊ณผ ๋น„๊ตํ•˜์—ฌ ์ด ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ์นดํƒˆ๋กœ๊ทธํ™”ํ•˜๋Š” ์ด์ ์€ ์ถ”๊ฐ€ ๊ฐœ๋ฐœ ๋˜๋Š” ๋””๋ฒ„๊น…์„ ์œ„ํ•ด ํŒŒ์ดํ”„๋ผ์ธ์„ ์‹คํ–‰ํ•˜์ง€ ์•Š๊ณ ๋„ ์ด ๋ฐ์ดํ„ฐ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ๋กœ ๋‹ค์‹œ ์‰ฝ๊ฒŒ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

catalog.load('cars')

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ