2016-03-22 6 views
0

ggplot facet_wrapタイプ引数yhat:私はは、私はtxtファイルを経由して読み込まパンダのデータフレームを持っているエラー

>> print training.columns.values
['segment' 'cookie_id' 'num_visits' 'num_page_views']

training = pd.read_csv('training_data.txt')

これらは列ですセグメントごとに「num_page_views」の密度を示すグラフに興味があります。

plot = ggplot(training, aes(x='num_visits')) + geom_density() 
     + xlim(0,20) + facet_wrap(~ 'segment') 
print plot 

そして、それは、次のエラー与える:

TypeError Traceback (most recent call last) in() 1 ----> 2 plot = ggplot(training, aes(x='num_visits')) + geom_density() +xlim(0,20) +facet_wrap(~ 'segment') 3 print plot

TypeError: bad operand type for unary ~: 'str'

答えて

2

引数yhat ggplotでは、ファセットオプションでは、 "〜" を取ることはありません。これはdocumentationにあります(便宜上ここにコピーされています):

import pandas as pd 

meat_lng = pd.melt(meat, id_vars=['date']) 

p = ggplot(aes(x='date', y='value'), data=meat_lng) 
p + geom_point() + \ 
    stat_smooth(colour="red") + \ 
    facet_wrap("variable") 

p + geom_hist() + facet_wrap("color") 

p = ggplot(diamonds, aes(x='price')) 
p + geom_density() + \ 
    facet_grid("cut", "clarity") 

p = ggplot(diamonds, aes(x='carat', y='price')) 
p + geom_point(alpha=0.25) + \ 
    facet_grid("cut", "clarity") 
+1

私は例を見ていますが、ドキュメントはありません。あなたは答えています: "これはドキュメントにあります(便宜上ここにコピーしてあります):" –

関連する問題