reset_index는 반환이 None이다...

SeongGyun Hong·2024년 10월 29일

문제가 되는 코드 및 에러메시지

target = video.sort_values('ct').groupby('videoname').last()
target['ratio'] = target.dislikecnt / target.likecnt
target.reset_index()
print(target)

answer = target[['videoname', 'ratio']]

위 코드에서...
자꾸 에러가 videoname이라는 칼럼 없다고 에러가 뜨고 있다.

문제 원인

target.reset_index()
이게 문제였다.
이건 내뱉는 반환값이 None이다... 원본을 바꾸지 않는 메서드...
그래서 이걸 제대로 담아주려면
target = target.reset_index()
해야한다...

해결

바꾸고나니 잘 작동하는 모습

profile
헤매는 만큼 자기 땅이다.

0개의 댓글