728x90
열 순서 바꾸기
def change_column_order(data , cols:list , positions:list) :
for position , col in zip(positions , cols) :
pop_ = data.pop(col)
data.insert(position, pop_.name, pop_.values)
return data
data = change_column_order(data , cols =["key"], positions=[0])'분석 Python > Pandas Tip' 카테고리의 다른 글
| [Pandas] Code to reduce memory (0) | 2021.01.01 |
|---|---|
| [Pandas] Pandas의 Filter 함수를 사용하여 특정 컬럼(변수) 제외하기 (0) | 2020.12.15 |
| [Python] Pandas를 활용하여 엑셀 시트별로 만들기 (0) | 2020.10.20 |
| [Python] pandas에서 데이터 더 빠르고 가볍게 읽는 방법 (1) | 2020.10.07 |
| [Pandas] 조건걸고 새로운 컬럼 추가하기 (1) | 2020.08.12 |