0

I have a dataframe named df1 where I have columns col_names = ['issuedate','channel','coupons','revenue'], and df is looking something like that:

   issuedate    channel     coupons     revenue
 0  2009-01-01  WWW        9999999     103082.98
 1  2010-01-01  Агенты     5           16518.01
 2  2010-01-01  КЦ         1           1137.22
 3  2010-01-01  С7 Билет   12          55239.87
 4  2010-01-01  ТКП        3           16800.00

After, I try to plot counts of channels in issuedate (channel_old is channel, that's not a point :)):

data7 = {     "BSP/ARC" : df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'BSP/ARC') ]['issuedate'],

              "WWW":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'WWW') ]['issuedate'],

              "Агенты":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'Агенты') ]['issuedate'],

              "КЦ":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'КЦ') ]['issuedate'],

              "Предст":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'Предст') ]['issuedate'],
              
              "С7 Билет":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'С7 Билет') ]['issuedate'],
            
               "ТКП":df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'ТКП') ]['issuedate'],

             };
dataFrame = pd.DataFrame(data=data7, columns = ["BSP/ARC","WWW","Агенты","КЦ","Предст","С7","Билет","ТКП"], index = pd.date_range(start='01/01/2010', end='01/01/2012', freq='M'))
dataFrame.plot.area(stacked=True);

So as a result I have a empty plot, that is wrong:

enter image description here

Whereas command like:

df1.loc[(df1['issuedate'] >= '01/01/2010') & (df1['issuedate'] <= '01/01/2012') & (df1['channel_old'] == 'С7 Билет') ]['issuedate']

works as right, and gives:

3      2010-01-01
9      2010-01-02
15     2010-01-03
21     2010-01-04
27     2010-01-05
          ...    
4765   2011-12-27
4772   2011-12-28
4779   2011-12-29
4786   2011-12-30
4792   2011-12-31
Name: issuedate, Length: 729, dtype: datetime64[ns]
chedreem
  • 11
  • 3
  • Welcome to Stack Overflow. Are you only struggling with producing the area plot? What is the second half of your post for? To improve and clarify your post, please remove any content not tied to your question and provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the data you are trying to plot. You can take a small sample of your dataframe (with the `dataFrame.sample(n=__)` method) and then post the data (you can get it with `df.to_dict('records')`). – AlexK Jun 05 '21 at 05:31
  • For more information, see [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391). – AlexK Jun 05 '21 at 05:31
  • Second half, as I already sad, is to clarify beginning, if anyone who wants to help me will want to see it. – chedreem Jun 05 '21 at 06:07
  • Dumping a bunch of code without an explanation of how it is tied to your question does not clarify anything. You are a lot more likely to receive assistance if you provide information only relevant to your specific question. – AlexK Jun 05 '21 at 06:10

0 Answers0