Source: youtu.be/0uBirYFhizE
ufo = pd.read_csv('http://bit.ly/uforeports')
ufo.head()

ufo.columns

ufo.rename(columns = {'Colors Reported':'Colors_Reported', 'Shape Reported':'Shape_Reported'}, inplace=True)
ufo.columns

ufo_cols = ['city', 'colors reported', 'shape reported', 'state', 'time']
ufo.columns = ufo_cols
ufo.head()

#파일을 불러오면서 columns 이름 자체를 바꿈
ufo = pd.read_csv('http://bit.ly/uforeports', name = ufo_cols, header = ())
ufo.head()

#type 많이 안해도 되는 rename 방법
ufo.columns

#space를 _로 대체함
ufo.colums = ufo.columns.str.replace(' ', '_')
ufo.columns

'둘 > [ Python ]' 카테고리의 다른 글
| How do I use the "axis" parameter in pandas? (0) | 2020.11.26 |
|---|---|
| How do I apply multiple filter criteria to a pandas DataFrame? (0) | 2020.11.26 |
| How do I filter rows of a pandas DataFrame by column value? (0) | 2020.11.26 |
| How do I sort a pandas DataFrame or a Series? (0) | 2020.11.26 |
| How do I remove columns from a pandas DataFrame? (0) | 2020.11.26 |