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
- NULL
- 사이킷런
- tfidfvectorizer
- 결측값
- 결측치
- ML
- 데이터프레임
- dataframe
- mask detection
- 이미지프로세싱
- 이미지처리
- dropna
- pandas
- Deep learning
- 지도학습
- 파이썬
- Python
- scikit-learn
- sklearn
- computer vision
- 알파브렌딩
- KNeighborsClassifier
- k-최근접 이웃 분류
- 비트와이즈
- NAN
- 판다스
- 머신러닝
- Supervised learning
- opencv
- index
Archives
- Today
- Total
Sun.El Data Analysis
[판다스] 데이터 정렬 : sort_values 본문
728x90
기본 사용법
df.sort_values(by,
axis=0,
ascending=True,
inplace=False,
kind='quicksort',
na_position='last',
ignore_index=False,
key=None)
1. by : 정렬 기준이 될 레이블
df.sort_values(by = 'col1')
df.sort_values(by = ['col1', 'col2'])
df.sort_values(by = ['col1', 'col2'])
2. axis : 정렬의 축 설정
df.sort_values(by = 'col1', axis=0) #열 기준 정렬, Na는 무시하고 정
df.sort_values(by= 'row5', axis=1) #행 기준 정렬, Na는 무시하고 정렬
3. ascending : 오름/내림차순
df.sort_values(by='col3', ascending=True) #오름차
df.sort_values(by='col3', ascending=False) #내림차순
4. na_position : Na값의 위치를 지정함
df.sort_values(by='col3', na_position='last') #결측값을 맨 뒤로 (기본값)
df.sort_values(by='col3', na_position='fist') #결측값을 맨 앞으로
5. ignore_index : index 초기화 설정 여부
df.sort_values(by='col3', ignore_index=True) #새로운 index로 재설정(0,1,2,3..)
df.sort_values(by='col3', ignore_index=False) #기존 index를 유지
6. inplace : 원본 대체 여부
df.sort_values(by='col3', inplace=True) #원본 대체
df.sort_values(by='col3', inplace=False) #원본 대체하지 않음
'Pandas' 카테고리의 다른 글
[판다스] 특정 조건의 행 또는 index 추출 (0) | 2023.07.15 |
---|---|
[판다스] 기존 DataFrame에 신규 칼럼을 추가할 경우 (0) | 2023.07.15 |
[판다스] DataFrame 결측값 처리 : df.dropna() (0) | 2023.07.15 |
[판다스] 데이터프레임 합칠때(pd.concat([df1,df2]), df1.append(df2) (0) | 2023.07.06 |
[판다스] 데이터프레임 칼럼명, 인덱스 다루기 (0) | 2023.07.04 |