Pandas - Plotting series

Viewed 566

I have a dataframe that is indexed by a datetime column and I get value_count() for various time ranges. For example,

data['leadsource_ch_disp_name'].ix[rng[0]].value_counts()

returns

Unknown        223
Sponsorship    889
Reseller       145
Referral        52
dtype: int64

which is a series. I want to do this with 5 different time ranges (rng[i] for i=[0,..,4]). So then I am left with 5 series. What I want to do is plot these 5 series (on the same plot) such that the x-axis is the series name and the y-axis is the values. And I want it to be a line graph with 4 lines (for unknown, sponsorship, reseller, and referral).

I have tried the following

rng0=data['leadsource_ch_disp_name'].ix[rng[0]].value_counts()
rng1=data['leadsource_ch_disp_name'].ix[rng[1]].value_counts()
rng2=data['leadsource_ch_disp_name'].ix[rng[2]].value_counts()
rng3=data['leadsource_ch_disp_name'].ix[rng[3]].value_counts()
rng4=data['leadsource_ch_disp_name'].ix[rng[4]].value_counts()
rng5=data['leadsource_ch_disp_name'].ix[rng[5]].value_counts()
pd.concat([rng0,rng1,rng2,rng3,rng4,rng5],axis=1).plot()

however, this does not return what I want. This creates a plot where the x-axis is Referral,reseller,sponsorship,unknown and there are 5 lines for the 5 different series.

1 Answers
Related