본문 바로가기

전체 글302

오랜만에 글... 오랜만에 글을 정리하는 것 같다... 올해 1월 초부터 연구소 입사 후에 몇 달간 치여 살아서 그런지 공부를 많이 못했다.. 틈틈이 계속 해야겠다... 2023. 4. 9.
결측치 처리 값으로 채우기 df.fillna(값) # 특정값으로 채우기 df.fillna(method='pad') # pad/ffill 앞선행의 값으로 채움 df.fillna(method='bfill') # bfill/backfill 다음 행의 값으로 채움 금융 시계열 분석에서는 보통 앞선 행의 값을 가져온다고 함(forward fill) 결측치 제거 df.dropna() df.dropna(axis = 'rows' or 'columns') df.dropna(axis = 0 or 1) 2023. 2. 20.
Datetime 다루기 날짜표현(STR -> DATETIME) import datetime format = '%Y-%m-%d %H:%M:%S' datetime_str = '2018-05-13 12:34:56' # STRING datetime_dt = datetime.datetime.strptime(datetime_str, format) # STRING -> DATETIME print(type(datetime_dt)) print(datetime_dt) 2018-05-13 12:34:56 날짜표현(DATETIME -> STR) datetime_str = datetime_dt.strftime('%Y-%m-%d %H:%M:%S') print(type(datetime_str)) # print(datetime_str) # 2018-08-.. 2023. 2. 19.
판다스 기본 학습 # 인덱스 차이 pd_series = pd.Series([1, 2, 3, 4], index=["일", "이", "삼", "사"]) pd_series_no_idx = pd.Series([1, 2, 3, 4]) index 있을 때 일 1 이 2 삼 3 사 4 dtype: int64 index 없을 때 0 1 1 2 2 3 3 4 dtype: int64 range pd.Series(range(100, 110)) 0 100 1 101 2 102 3 103 4 104 5 105 6 106 7 107 8 108 9 109 dtype: int64 인덱스 접근 pd_series.index Index(['일', '이', '삼', '사'], dtype='object') 값 접근 pd_series.values array([.. 2023. 2. 19.