You can try this also to avoid KeyError
, hope the below code will solve your issue:
import pandas as pd
data = pd.DataFrame([i.split() for i in open("intC.txt", "r").readlines()])
data.columns = data.iloc[0]
data = data.iloc[1: , :]
data['TXBS'] = pd.to_numeric(data['TXBS'], errors='coerce')
mysort = data.sort_values(by=['TXBS'], ascending=False)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.