๐Ÿš€ Languege/Python 13

python - numpy(2) 2์ฐจ์› ๋ฐฐ์—ด

2์ฐจ์› ๋ฐฐ์—ด์ด๋ž€, ํ‘œ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค! 2์ฐจ์› ๋ฐฐ์—ด import numpy as np # 2X3 ํ–‰๋ ฌ c = np.array([[0, 1, 2], [3, 4, 5]]) # ๋‚ด๋ถ€ ์Šคํ€˜์–ด๋ธŒ๋ผ์ผ“์ด ํ–‰, ์š”์†Œ๊ฐ€ ์—ด print(' 2x3 ํ–‰๋ ฌ\n', c) print('ํ–‰์˜ ๊ฐœ์ˆ˜ :', len(c)) print('์—ด์˜ ๊ฐœ์ˆ˜ :', len(c[1])) print('c[0]์˜ ๊ฐ’ :', c[0]) print('c[1]์˜ ๊ฐ’ :', c[1]) [์‹คํ–‰ ๊ฒฐ๊ณผ] 2x3 ํ–‰๋ ฌ [[0 1 2] [3 4 5]] ํ–‰์˜ ๊ฐœ์ˆ˜ : 2 ์—ด์˜ ๊ฐœ์ˆ˜ : 3 c[0]์˜ ๊ฐ’ : [0 1 2] c[1]์˜ ๊ฐ’ : [3 4 5]

python - numpy(1) 1์ฐจ์› ๋ฐฐ์—ด

numpy๋ž€, ์ˆ˜์น˜ ํ•ด์„์šฉ ํŒŒ์ด์ฌ ํŒจํ‚ค์ง€! 1์ฐจ์›~3์ฐจ์› ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 1์ฐจ์› ๋ฐฐ์—ด import numpy as np # numpy์˜ 1์ฐจ์› ๋ฐฐ์—ด------------------------------- # arrryํ•จ์ˆ˜์— ๋ฆฌ์ŠคํŠธ๋ฅผ ๋„ฃ์œผ๋ฉด ๋ฐฐ์—ด๋กœ ๋ณ€ํ™˜ ar = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # ndarray ์ž๋ฃŒํ˜•์ด๊ณ  , ()์•ˆ์— ์‹œํ€€์Šค ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค. print(ar) print('ar ์ž๋ฃŒํ˜• :', type(ar)) # ๋ฐฑํ„ฐํ™” ์—ฐ์‚ฐ-------------------------------------- data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # 1.for๋ฌธ์„ ์ด์šฉํ•œ ์—ฐ์‚ฐ๋ฐฉ์‹ answer = [] for di in d..

728x90