반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Do_it
- 집 값 예측 분석
- DFS
- Extended Slices
- Do it
- matplotlib
- MacOS
- 순열
- 프로그래머스
- sql
- 점프 투 파이썬
- 다익스트라 알고리즘
- 타입 변수
- 박스그래프
- 습작
- np.zeros_like
- 이것이 취업을 위한 코딩테스트다
- 이진수 변환
- 팩토리얼 진법
- 자바
- mysql
- 2BPerfect
- java
- dacon
- 브라우저 실행
- jdbc
- 백준
- BFS
- PYTHON
- 참조 변수
Archives
- Today
- Total
🦕 공룡이 되자!
Pandas 재정리 데이터 전처리 본문
조건
- 조건에 맞는 값 변경조건값
-
# grades 값이 80 이라면 result 는 'B' df.loc[df['grades'] == 80, 'result'] = 'B' # result 값이 'A' 나 'B' 가 아니라면 result 는 'F’ df.loc[df['result'] != ('A' or 'B') , 'result'] = 'F’
- 조건값
-
df[~df['컬럼명'].isin(['값','값2'])] # 반대 조건 df[~df['컬럼명'].isin(['값','값2'])]
날짜형식으로 변경
- pd.to_datetime
- order_all['delivered_date']=pd.to_datetime(order_all['delivered_date'])
- 연도 추출
-
df['year'] = pd.DatetimeIndex(df['ArrivalDate']).year df['year'] = df['ArrivalDate'].dt.year
- 월 추출
-
df['month'] = pd.DatetimeIndex(df['ArrivalDate']).month df['month'] = df['ArrivalDate'].dt.month
- 원하는 형식으로 추출
-
order_all['delivered_month'] = order_all['delivered_date'].apply(lambda x:x.strftime('%Y%m'))
반응형
'Development > Python' 카테고리의 다른 글
Pandas 재정리 값 수정 (0) | 2022.02.12 |
---|---|
Pandas 통계 예시(그래프 유사도 측정) (0) | 2022.02.11 |
Numpy zeros관련 (0) | 2022.02.09 |
ex(첨도, 분산,박스) (0) | 2022.02.07 |
Matplotlib...3(그래프 옵션 2) (0) | 2022.02.06 |
Comments