목록Programming (97)
59doit
drop ▷ obj = pd.Series(np.arange(5.), index=['a', 'b', 'c', 'd', 'e']) obj # # a 0.0 # b 1.0 # c 2.0 # d 3.0 # e 4.0 # dtype: float64 new_obj = obj.drop('c') new_obj # # a 0.0 # b 1.0 # d 3.0 # e 4.0 # dtype: float64 obj.drop(['d', 'c']) # # a 0.0 # b 1.0 # e 4.0 # dtype: float64 ▷ 데이터 프레임만들기 data = pd.DataFrame(np.arange(16).reshape((4,4)), index =['Ohio','Colorado','Utah','New York'],columns=[..
index import pandas as pd import numpy as np ▷ obj = pd.Series(range(3),index=['a','b','c']) index = obj.index index # Index(['a', 'b', 'c'], dtype='object') index[1:] # Index(['b', 'c'], dtype='object') ▷ 인덱스 안의 인덱스 변경은 불가 Error index[1] = 'd' # # TypeError: Index does not support mutable operationserror ▷ 인덱스 컬럼명을 범위값으로 지정하고 index가 있는지확인 is & in is labels = pd.Index(np.arange(3)) labels # Int6..
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 ;..