강의

멘토링

커뮤니티

Inflearn Community Q&A

freedom07's profile image
freedom07

asked

Mastering data analysis and visualization with just two pages of documentation

11) Reshaping DataFrames with df.sort_values, rename, sort_index, and reset_index

선생님 index를 1부터 시작하게 하려면

Written on

·

402

1

선생님 강의에 df 를 보면 인덱스가 

0부터 시작하잖아요~

df의 index를 1부터 시작하게 하려면

어떤 기능을 써야 하나요?ㅠㅠ

(행 개수가 많을 때 reindex나 rename을 못해주는 경우에)

pythonpandas

Answer 3

1

freedom07님의 프로필 이미지
freedom07
Questioner

아하!!  선생님 빠르고 정확한 답변 정말 너무 감사합니다..ㅠㅠ!!! 

0

todaycode님의 프로필 이미지
todaycode
Instructor

감사합니다 :)

0

todaycode님의 프로필 이미지
todaycode
Instructor

안녕하세요.

shape를 하면 행과 열의 수가 나오는데 df.shape[0] 으로 행의 수를 가져올 수 있어요.

df.index = range(1, df.shape[0]+1) 로 인덱스를 1부터 시작하게 설정할 수 있어요.

freedom07's profile image
freedom07

asked

Ask a question