2

identityPython ggplot ライブラリを使用して、非常に単純な棒グラフを描画したいと考えています。x 軸にいくつかのカテゴリ変数があり、y 軸に変数があり、棒グラフに y 軸の値を入力したいと考えています。

import pandas as pd
from ggplot import *
import numpy as np

a= pd.DataFrame(np.arange(5) ,  index = np.arange(5))
a['second_column'] = ['a', 'b', 'c', 'd', 'e']
a.columns = ['first_column', 'second_column']
ggplot(aes(x = 'second_column', y = 'first_column'), data = a) + \
geom_bar(aes(fill = 'first_column'), stat='identity')

私が得るものは次のとおりです。

<repr(<ggplot.ggplot.ggplot at 0x7f2d70cc12d0>) failed: ValueError: Cannot convert argument type <type 'numpy.int64'> to rgba array>

fill一方、美学から削除すると:

a= pd.DataFrame(np.arange(5) ,  index = np.arange(5))
a['second_column'] = ['a', 'b', 'c', 'd', 'e']
a.columns = ['first_column', 'second_column']

ggplot(aes(x = 'second_column', y = 'first_column'), data = a) + \
geom_bar(stat='identity')

エラーがなく、適切な出力が得られます。

ここに画像の説明を入力

4

0 に答える 0