问答详情
源自:5-3 pandas基本操作

按照老师的代码执行报错AttributeError: 'DataFrame' object has no attribute 'sort'


执行到

print(df.sort(columns="C"))


报错

AttributeError                            Traceback (most recent call last)
<ipython-input-12-8629de499749> in <module>
----> 1 print(df.sort(columns="C"))

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5065             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5066                 return self[name]
-> 5067             return object.__getattribute__(self, name)
   5068
   5069     def __setattr__(self, name, value):

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

提问者:qq_慕妹123522 2019-08-11 07:50

个回答

  • qq_慕妹123522
    2019-08-11 07:52:30

    提问了发现后面有答案了,删不掉提问。就自己回答了:改为 print(df.sort_values('C'))