Pandas 라이브러리 소개 - 데이터 분석을 위한 파이썬 기반의 라이브러리 - 2차원 데이터를 효율적으로 가공 및 처리할 수 있는 강력한 라이브러리 - https://pandas.pydata.org/ pandas - Python Data Analysis Library pandas pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language. Install pandas now! pandas.pydata.org pandas is a fast, powerful, flexible and easy to us..
NumPy는 ndarray 내 저장된 데이터의 정렬을 위한 함수를 제공한다. np.sort(array) - 기본적으로 오름차순 정렬만 지원함 - 정렬된 결과를 반환하지만, 원본 데이터는 변경하지 않음 - 원본 데이터를 변경하려면 호출 순서를 다음과 같이 작성하면 됨 - array.sort(): 원본 데이터를 변경하고 none 값을 반환 - np.sort()를 활용한 내림차순 정렬 1) np.sort()를 통해 오름차순 정렬하여 저장 2) 오름차순 정렬된 배열을 역순으로 출력: array[::-1] np.sort(array, axis) - 기본적으로 1차원 정렬과 동일함 - 2차원 데이터의 정렬 시에는, axis를 통해 집계 방향을 결정함 np.argsort(array) - 입력된 배열을 오름차순으로 정렬..
NumPy의 Index(인덱스) - 배열 내 특정 데이터는 인덱스를 통해 접근할 수 있음 - Indexing을 통한 조회방법: array[index], array[index, index], array[index, index, index], ... import numpy as np # 1차원 샘플 데이터 생성 sample = np.arange(5,15) print('1D-Array Sample:', sample) print('sample[3] = ', sample[3]) # 인덱싱 값 변경 후 출력 sample[3] = 0 print('1D-Array Sample:', sample) # 2차원 샘플 데이터 생성 sample = np.arange(16).reshape((4,4)) print('\n2D-Arr..
집계 함수(Aggregate Functions) - 데이터를 종합하여 특정 연산을 적용하는 함수들을 총칭 - 합계: sum() - 최소값: min() - 최대값: max() - 누적합계: cumsum() - 평균: mean() - 중앙값: median() - 상관계수: corrcoef() - 표준편차: std() - 고유값: unique() - 집계 함수의 기능 이해와 사용법은 매우 단순함 # 방법1 array.sum() # 방법2 np.sum(array) - 중요한 것은 데이터의 집계 방향을 지정해야함 - axis=None(defalut): 대상 ndarray의 모든 요소가 연산 대상이 됨 - axis=0: 열을 기준으로 동일 인덱스의 요소를 그룹으로 연산함 - axis=1: 행을 기준으로 동일 인덱스..
NumPy의 기본 연산 - 연산자(+, -, *, /, >, b print('\nResult of comparison operator(>)') print(result) ''' # NumPy 의 비교연산(!=) ''' result = a != b print('\nResult of comparison operator(!=)') print(result) ''' # Python 코드 실행 시간 측정하기 ''' python_arr = range(10000000) start = time.time() for i in python_arr: i + 1 print("\nPython(ms):", (time.time() - start)*1000) ''' # NumPy 코드 실행 시간 측정하기 ''' numpy_arr = np..