2016-07-29 25 views
2

私の目標は 'score'を 'label'で囲み、「date」と「Cusip」は気にしません。私は 'ピボット'を使用してデータの形を変え、各ラベルが1列にあり、ボックスプロットすることができます。ピボットテーブルエラー:1 ndimカテゴリは現時点ではサポートされていません

   date Cusip Label Score 
663182 2015-07-31 00846UAG AAA 138.15 
663183 2015-07-31 00846UAH AAA 171.93 
663184 2015-07-31 00846UAJ AAA 175.67 
663185 2015-07-31 023767AA BB 187.92 
663186 2015-07-31 023770AA BB 176.25 

t.pivot(index=['date','Cusip'],columns='Label',values='Score') 

エラーを示しています。

NotImplementedError: > 1 ndim Categorical are not supported at this time 

詳細:あなたのdate列に重複したエントリを持っているよう

C:\Anaconda3\lib\site-packages\pandas\core\categorical.py in __init__(self, values, categories, ordered, name, fastpath, levels) 
    285    try: 
--> 286     codes, categories = factorize(values, sort=True) 
    287    except TypeError: 

C:\Anaconda3\lib\site-packages\pandas\core\algorithms.py in factorize(values, sort, order, na_sentinel, size_hint) 
    184  uniques = vec_klass() 
--> 185  labels = table.get_labels(vals, uniques, 0, na_sentinel, True) 
    186 

pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_labels (pandas\hashtable.c:13921)() 

ValueError: Buffer has wrong number of dimensions (expected 1, got 2) 

答えて

2

あなたは本当にpivot_tableを使用する必要があります。

pd.pivot_table(df, values='Score', index=['date', 'Cusip'], columns=['Label']).boxplot() 

alt text

関連する問題