2

I want to sort the excel file worksheet called "LTE_PrbUtil" and it has a column called "CELL" which is string descending. When I run the program and find some error:

  File "C:\Users\p4532\Desktop\QGIS_project\highloading.py", line 18, in <module> df = df.sort(columns="CELL")
  File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 3081, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'sort'`

Here is my code:

import shutil
import pandas as pd
import xlrd
xl=pd.ExcelFile("C:\Users\p4532\Desktop\QGIS_project\HighUtilCells_new.xlsx")                                                                           
df = xl.parse("LTE_PrbUtil")
df = df.sort(columns="CELL")

It seems the dataframe cannot recognize sort. Can anyone help?

1
  • sort is deprecated. Commented Oct 17, 2017 at 3:06

1 Answer 1

3

Use sort_values:

df = df.sort_values('CELL')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.