Pandas 컬럼명 변경

1 개요[ | ]

Pandas 컬럼명 변경
Pandas 변수명 변경

2 컬럼명 지정[ | ]

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
df.head(2)
df.rename(columns={"sepal_length":"aaa","petal_length":"bbb"}, inplace=True)
df.head(2)

3 컬럼위치 지정[ | ]

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
df.head(2)
df.rename(columns={df.columns[0]:"aaa",df.columns[2]:"bbb"}, inplace=True)
df.head(2)

4 전체 재설정[ | ]

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv")
df.head(2)
df.columns = ['aaa','sepal_width','bbb','petal_width','species']
df.head(2)

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}