Pandas - Section Series

I have a dataframe that is indexed by a datetime column, and I get value_count () for different 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 near. I want to do this with 5 different time intervals ( rng[i]for i = [0, .., 4]). So, I stayed with 5 episodes. What I want to do is build these 5 rows (on the same graph) that the x axis is the name of the series and the y axis is the values. And I want it to be a line graph with 4 lines (for unknowns, sponsors, resellers and referrals).

I 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 graph in which the x axis is direction, reseller, sponsorship, suspense, and 5 lines for 5 different episodes.

+4
1

plot() , .

pd.concat([rng0,rng1,rng2,rng3,rng4,rng5],axis=1).T.plot()
+3

All Articles