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 |
Tags
- count()
- elbow method
- wcss
- append()
- 덴드로그램
- DataAccess
- list
- 최솟값
- Dictionary
- len()
- pandas
- hierarchical_clustering
- dendrogram
- IN
- 분류 결과표
- Machine Learning
- insert()
- function
- Python
- DataFrame
- analizer
- 반복문
- data
- 최댓값
- numpy
- del
- string
- matplotlib
- sklearn
- nan
Archives
- Today
- Total
개발공부
[Python] Pandas Dataframe 인덱스, 컬럼명 변경하기(rename()), 컬럼을 인덱스로 사용하기(set_index(),reset_index()) 본문
Python/Pandas
[Python] Pandas Dataframe 인덱스, 컬럼명 변경하기(rename()), 컬럼을 인덱스로 사용하기(set_index(),reset_index())
mscha 2022. 5. 2. 12:08df

인덱스명 변경
# store 3 를 last store 로변경하기
df.rename( index = {'store 3' : 'last store'} )

컬럼명 변경
# bikes 컬럼을 hat 으로 바꾸고, suits 컬럼은 shoes 로 바꾸기
df.rename ( columns= {'bikes' : 'hat', 'suits' : 'shoes'})

컬럼을 인덱스로 사용 set_index()
df

# name 컬럼을 인덱스로 사용하고 싶을 때
# set_index()를 사용한다
# inplace = True => 원본 데이터 변경 여부
df.set_index('name', inplace = True)
df

사용했던 컬럼을 원래대로 되돌리기 reset_index()
df.reset_index(inplace=True)
df

'Python > Pandas' 카테고리의 다른 글
| [Python]Pandas 카테고리컬 데이터 확인하기, 이를 묶어 처리하기 groupby() (0) | 2022.05.03 |
|---|---|
| [Python] Pandas Dataframe NaN 다루기 (0) | 2022.05.02 |
| [Python] Pandas Dataframe 열과 행 생성, 삭제(append(), drop()) (0) | 2022.05.02 |
| [Python] Pandas Dataframe 생성, csv읽기, 저장하기, 데이터 액세스 (0) | 2022.05.02 |
| [Python] Pandas Series 생성, 데이터 액세스, 산술 연산 (0) | 2022.05.02 |