목록Programming/Python(파이썬) (44)
59doit
import pandas as pd Series, DataFrame 를 로컬 네임스페이스로 import from pandas import Series, DataFrame 설정 import numpy as np np.random.seed(12345) import matplotlib.pyplot as plt plt.rc('figure', figsize=(10, 6)) PREVIOUS_MAX_ROWS = pd.options.display.max_rows pd.options.display.max_rows = 20 np.set_printoptions(precision=4, suppress=True) pd.options.display.max_rows = PREVIOUS_MAX_ROWS ▷ 다중인덱스 사용가능 obj..

▷ .reshape arr = np.arange(32).reshape(8,-1) arr # # array([[ 0, 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]]) shape은 (차원, 행, 열) ▷ .mean & .sum arr = np.random.randn(5,4) arr arr.mean() np.mean(arr) # -0.15612707816159727 # arr.mean() = np.mean(arr) 값이 똑같다 arr.sum() # -3.1225415632319455 ▷ axis ;..

import numpy as np 유니버설함수 arr = np.arange(10) arr # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) 단항 유니버설 함수 np.sqrt(arr) # # array([0. , 1. , 1.41421356, 1.73205081, 2. , # 2.23606798, 2.44948974, 2.64575131, 2.82842712, 3. ]) np.exp(arr) # # array([1.00000000e+00, 2.71828183e+00, 7.38905610e+00, 2.00855369e+01, # 5.45981500e+01, 1.48413159e+02, 4.03428793e+02, 1.09663316e+03, # 2.98095799e+03, 8.10308..
import numpy as np 브로드캐스팅(broadcasting) arr = np.arange(10) arr # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) arr[5] # 5 arr[5:8] # array([5, 6, 7]) arr[5:8] = 12 # 5,6,7 자리에 12를 넣어라 arr # array([ 0, 1, 2, 3, 4, 12, 12, 12, 8, 9]) ▷ # # array([ 0, 1, 2, 3, 4, 12, 12, 12, 8, 9]) arr 슬라이스 생성 # # array([ 0, 1, 2, 3, 4, 12, 12, 12, 8, 9]) arr_slice = arr [5:8] arr_slice # array([12, 12, 12]) arr_slice 값 변..