강의

멘토링

로드맵

Inflearn Community Q&A

anotheratelier2121's profile image
anotheratelier2121

asked

Getting started with Python data analysis using public data

[9/20] Expressing grouped data in various forms using Pandas' visualization function

AttributeError: 'Series' object has no attribute 'sort'

Written on

·

3.2K

1

안녕하세요 선생님, 강의 잘 듣고있습니다. 

판다스 시각화-선그래프 수업 도중, 

sort명령어를 통해 정렬하는 부분에서 에러메시지가 발생했어요! 코드를 그대로 따라하며 수행중이었는데 무엇이 문제였을까요?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-74-0e97ee86be4d> in <module>
      1 # 지역명으로 분양가격의 평균을 구하고 막대그래프(bar)로 시각화 합니다.
----> 2 g = df_last.groupby(["지역명"])["평당분양가격"].mean().sort.values(ascending=False)
      3 g   #그룹화된 데이터 g변수에 저장
      4 # g.plot(kind="bar")
      5 g.plot.bar(rot=0, figsize=(10, 3))

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5463             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5464                 return self[name]
-> 5465             return object.__getattribute__(self, name)
   5466 
   5467     def __setattr__(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'sort'



pandasnumpypython

Answer 1

0

todaycode님의 프로필 이미지
todaycode
Instructor

안녕하세요!

오류중에 가장 찾기 어려운 오타 오류에요.

아래와 같이 변경해 보세요 :)

sort.values => sort_values()
anotheratelier2121's profile image
anotheratelier2121

asked

Ask a question