0

DGroup=df.groupby(['Conmer id','Purchase date']).count()

Conmer id Purchase date A B C D

2397 2017-07-29 19:05:24 1 1 1 1

4107 2016-03-31 19:06:54 1 0 0 1

         2016-04-01 05:41:55        1         0          0     1  

         2016-04-02 06:18:16        1         0          0     1  

         2016-04-03 05:28:02        1         0          0     1  

         2016-04-04 05:47:08        1         0          0     1  

         2016-04-05 05:15:10        1         0          0     1  

         2016-04-09 05:40:06        1         0          0     1  

         2016-04-10 05:02:34        1         0          0     1  

         2016-04-11 05:06:18        1         0          0     1  

.... 234 2016-03-31 11:06:54 1 0 0 1

         2016-04-01 05:41:55        1         0          0     1  

         2016-04-02 16:18:16        1         0          0     1  

         2016-04-03 15:28:02        1         0          0     1  

         2016-04-04 15:47:08        1         0          0     1  

         2016-04-05 15:15:10        1         0          0     1  

         2016-04-09 15:40:06        1         0          0     1  

         2016-04-10 11:02:34        1         0          0     1  

         2016-04-11 13:06:18        1         0          0     1

2634 2015-08-16 18:26:46 1 1 1 1 0

2017-11-30 11:42:50 1 1 1 1 0 2017-12-01 06:14:47 1 1 1 1 0 2017-12-02 06:09:43 1 1 1 1 0

.... now how i can get individual consumer id from this grouped data with cunsumer id and date (with the entire row) in to another variable for plotting and analysing?

Sam Joe
  • 13
  • 6
  • can you show us expected output and your efforts? – Sociopath Feb 12 '18 at 09:40
  • Sorry, you need `.xs`, so changed dupe. – jezrael Feb 12 '18 at 09:48
  • DGroup is not what i am looking, i wanted to take out consumer 4107 all values which i got after grouping as above to another variable. currently all consumers values are listed , but i need to take out single consumer 2016,2017 data from the above format to a variable. – Sam Joe Feb 12 '18 at 09:50
  • 'for Conmer id, group in grouped: group.to_csv('/Users/path'+str(Conmer id)'.csv' print Conmer id print group' above code is used to save and print each grouped data separately and – Sam Joe Apr 11 '18 at 06:16

0 Answers0