2015-03-02 39 views
0

我正在嘗試按列「DayOfYear」進行數字排序,但它不允許我將它轉換爲帶有熊貓的數據框,但是我沒有使用數字排序的運氣按列Python的數字排序

results7 = ([['1', '660.206159375', '2200.969', '1588.2815', '831.8674', 
    '521.3459', '329.77015', '205.89374', '102.9523'], 
    ['10', '932.475360938', '2381.846', '2098.8083', '1289.0055', 
    '780.2308', '522.78565', '340.15073', '298.4486'], 
    ['11', '914.067898437', '2698.957', '1922.7277', '1259.1625', 
    '731.6858', '505.171', '267.1976', '203.4595'], 
    ['12', '786.08815', '2580.748', '1823.5057', '908.63865', 
    '652.7224', '455.6254', '229.1738', '146.3479'], 
    ['2', '928.879345312', '3075.417', '2560.8875', '1166.789', 
    '734.7388', '512.9898', '241.98641', '167.2151'], 
    ['', nan, nan, nan, nan, nan, nan, nan, nan]], dtype=object 
    ]) 

names50 = ['DayOfYear','AvgFlow','Max','n95th','n75th','n50th','n25th','n5th','Min'] 
results9 = pd.DataFrame(results8,columns=names50) 
results10 = results9.astype(str).convert_objects(convert_numeric=True) 

results11 = results10[~np.isnan(results10).any(axis = 1)] 
results12 = np.sort(results11, order = 'DayOfYear') 

我收到的

ValueError: Cannot specify order when the array has no fields.

錯誤消息當我把它轉換成一個pd.DataFrame難道我不指定領域還當我嘗試做我收到一條錯誤消息.dtype:

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

我在這裏做錯了什麼?

+0

這真的results7在上面定義的?如果是這樣,你能提供一個定義result8(傳遞給DataFrame構造函數的定義)嗎? – Alex 2015-03-02 16:34:43

+0

您當前的帖子代碼不會重現您的錯誤,或者至少我無法運行它,您是否可以發佈最小代碼來重現您的錯誤 – EdChum 2015-03-02 16:34:52

+0

DataFrames沒有'dtype',DataFrame列。 – Alexander 2015-03-02 16:35:06

回答

相關問題