使用pandassortingexcel列
我想sorting名为“LTE_PrbUtil”的Excel文件工作表,它有一个名为“CELL”的string降序列。 当我运行该程序,并发现一些错误:
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'`
这是我的代码:
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")
看来数据框无法识别sort
。 谁能帮忙?
使用sort_values
:
df = df.sort_values('CELL')