I have a pandas dataframe
that I read in via txt file:
training = pd.read_csv('training_data.txt')
These are the columns:
>> print training.columns.values`
['segment' 'cookie_id' 'num_visits' 'num_page_views']
I'm interested in a graph that shows the density of num_page_views
by segment, like so:
plot = ggplot(training, aes(x='num_visits')) + geom_density()
+ xlim(0,20) + facet_wrap( ~ 'segment')
print plot
And it gives the following error:
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'