일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- math
- Redshift
- Mac
- matplotlib
- Excel
- dataframe
- PySpark
- list
- Google Excel
- PANDAS
- Kotlin
- Python
- c#
- 파이썬
- array
- django
- SQL
- numpy
- Tkinter
- Google Spreadsheet
- gas
- google apps script
- string
- PostgreSQL
- Github
- Java
- hive
- Apache
- GIT
- Today
- Total
목록array (17)
달나라 노트
numpy의 ndim attribute는 어떤 array가 몇차원인지를 알려줍니다. 아래는 ndim attribute를 사용한 예시입니다. import numpy as np arr_test = np.array( [1, 2, 3, 4, 5] # 1차 array ) print(arr_test) print(arr_test.ndim) -- Result [1 2 3 4 5] 1 import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5] # 2차 array ] ) print(arr_test) print(arr_test.ndim) -- Result [[1 2 3 4 5] [1 2 3 4 5] ..
array에 10이라는 숫자만 전달하면 위처럼 그냥 숫자데이터가 나옵니다. 별도로 import numpy as np arr_test = np.array(10) print(arr_test) -- Result 10 이것을 1행 1열의 데이터로 바꾸고싶으면 어떻게할까요. 이때 reshape method를 사용할 수 있습니다. import numpy as np arr_test = np.array(10) print(arr_test) arr_test = arr_test.reshape(1, 1) print(arr_test) -- Result 10 [[10]] 위처럼 reshape을 사용하면 [[10]] 처럼 1행 1열의 데이터로 변환되었습니다. - reshape(1, 1) 1 by 1(1 x 1) 데이터로 변환하라는..
numpy의 array method는 numpy array를 만들어줍니다. import numpy as np arr_1 = np.array([1, 2, 3, 4, 5]) print(arr_1) -- Result [1 2 3 4 5] 사용법은 간단합니다. array method의 인자로서 array로 만들 데이터를 전달해주면 됩니다. 위 예시는 list를 array로 만드는 예시입니다. list 속에 또 다른 list가 없고 단순히 숫자만 존재하므로 1차원 데이터입니다. import numpy as np arr_2 = np.array([[1, 2], [3, 4]]) print(arr_2) -- Result [[1 2] [3 4]] 위 예시도 동일한 형태지만 다른 점은 array로 만들 list에 있습니다...
public class JavaList { public static void main(String args[]) { ArrayList arr_list = new ArrayList(); arr_list.add("one"); arr_list.add("two"); arr_list.add("three"); System.out.println(arr_list); System.out.println(arr_list.get(0)); System.out.println(arr_list.get(1)); System.out.println(arr_list.get(2)); // System.out.println(arr_list.get(3)); // index=3은 없으므로 error 발생 // remove를 이용하여 list의 요..