데이터 조작 및 분석을 위한 Pandas 심화
데이터프레임 정렬하기 인덱스, 컬럼값으로 정렬할 수 있음. Index, Column 기준으로 정렬하기 axis = 0 : 행 인덱스 기준 정렬(Default 오름차순) ascending = False : 오름차순 / Tru : 내림차순 import numpy as np import pandas as pd print("DataFrame: ") df = pd.DataFrame({ 'col1' : [2, 1, 9, 8, 7, 4], 'col2' : ['A', 'A', 'B', np.nan, 'D', 'C'], 'col3': [0, 1, 9, 4, 2, 3], }) print(df, "\n") # ..
배열의 기초
배열의 데이터 타입 dtype 파이썬 리스트와 달리 같은 데이터 타입만 저장 가능. arr = np.array([0, 1, 2, 3, 4], dtype =float) print(arr) # [0. 1. 2. 3. 4.] print(arr.dtype) # 'float64' print(arr.astype(int)) # 정수형 변환 [0 1 2 3 4]dtype 의 종류 dtype 설명 다양한 표현 int 정수형 타입 i, int_, int32, int64, i8 float 실수형 타입 f, float_, float32, float64, f8 ol_ 문자열 타입 str, U, U32 bool 부울 타입 ?, bool ndarray의 차원 관련 속성 ndim : n+dimension 몇 차원인가?..