title: Double for loop over Pandas df
body: <p>I have a dataframe containing a column of subreddits and another column containing authors who have commented in that subreddit. Here is a snapshot:</p>
  
  <pre><code>subreddit                                                         user
  0xProject            [7878ayush, Mr_Yukon_C, NomChompsky92, PM_ME_Y...
  100sexiest                                                   [T10rock]
  100yearsago                                       [PM_ME_MII, Quisnam]
  1022                           [MikuWaifuForLaifu, ghrshow, johnnymn1]
  1200isjerky                             [Rhiann0n, Throwaway412160987]
  1200isplenty         [18hourbruh, Bambi726, Cosmiicao, Gronky_Kongg...
  1200isplentyketo                                             [yanqi83]
  12ozmouse                                                     [ChBass]
  12thMan                                      [8064r7, TxAg09, brb1515]
  12winArenaLog                                                  [fnayr]
  13ReasonsWhy                                    [SawRub, _mw8, morbs4]
  13or30                                          [BOTS_RISE_UP, mmcjjc]
  14ers                                                      [BuccoFan8]
  1500isplenty                                                  [nnowak]
  15SecondStories                               [DANKY-CHAN, NORMIESDIE]
  18650masterrace                                               [Airazz]
  18_19                [-888-, 3mb3r89, FuriousBiCurious, FusRohDoing...
  1911                 [EuphoricaI, Frankshungry, SpicyMagnum23, cnw4...
  195                                                 [RobDawg344, ooi_]
  19KidsandCounting                  [Kmw134, Lvzv, mpr1011, runjanarun]
  1P_LSD               [420jazz, A1M8E7, A_FABULOUS_PLUM, BS_work, EL...
  2007oneclan                                                    [J_D_I]
  2007scape            [-GrayMan-, -J-a-y-, -Maxy-, 07_Tank, 0ipopo, ...
  2010sMusic                                                    [Vranak]
  21savage                                                     [Uyghur1]
  22lr                                                      [microphohn]
  23andme              [Nimushiru, Pinuzzo, Pugmas, Sav1025, TOK715, ...
  240sx                [I_am_a_Dan, SmackSmackk, jimmyjimmyjimmy_, pr...
  24CarrotCraft                                                [pikaras]
  24hoursupport        [GTALionKing, Hashi856, Moroax, SpankN, fuck_u...
                                             ...                        
  youtubetv                                [ComLaw, P1_1310, kcamacho11]
  yoyhammer             [Emicrania, Jbugman, RoninXiC, Sprionk, jonow83]
  ypp                                                           [Loxcam]
  ypsi                                                           [FLoaf]
  ytp                                                         [Profsano]
  yugijerk                                             [4sham, Exos_VII]
  yugioh               [1001puppys, 6000j, 8512332158, A_fiSHy_fish, ...
  yumenikki                                                      [ripa9]
  yuri                 [COMMENTS_ON_NSFW_PIC, MikuxLuka401, Pikushibu...
  yuri_jp                                                    [Pikushibu]
  yuruyuri                    [ACG_Yuri, KirinoNakano, OSPFv3, SarahLia]
  zagreb                                                      [jocus985]
  zcoin                                                      [Fugazi007]
  zec                  [Corm, GSXP, JASH_DOADELESS_, PSYKO_Inc, infinis]
  zedmains             [BTZx2, EggyGG, Ryan_A121, ShacObama, Tryxi, m...
  zelda                [01110111011000010111, Aura64, AzaraAybara, BA...
  zen                  [ASAMANNAMMEDNIGEL, Cranky_Kong, Dhammakayaram...
  zerocarb                            [BigBrain007, Manga-san, vicinius]
  zetime                                                        [xrnzrx]
  zfs                  [Emachina, bqq100, fryfrog, michio_kakus_hair,...
  ziftrCOIN                                                      [GT712]
  zoemains             [DrahaKka, OJSaucy, hahAAsuo, nysra, x3noPLEB,...
  zombies                                             [carbon107, rjksn]
  zomby                                                        [jwccs46]
  zootopia             [BCRE8TVE, Bocaj1000, BunnyMakingAMark, Far414...
  zumba                                                   [GabyArcoiris]
  zyramains                                       [Dragonasaur, Shaiaan]
  zyzz                                                            [Xayv]
  </code></pre>
  
  <p>I am trying to iterate over every subreddit and then iterate over every subreddit beneath that to find shared commenters.  The end goal is a dataframe containing subreddit 1, subreddit 2, and the number of shared commenters. </p>
  
  <p>I can't even conceive of how to do this using apply, and not sure how to do a double for loop with pandas df's.</p>
  
  <p>Is this the right idea?</p>
  
  <pre><code>for i in df2.index:
    subreddit = df2.get_value(i,'subreddit')
      for i+1 in df2.index:
        ...
  </code></pre>
  
  <p>Here's an example of input and intended output:</p>
  
  <pre><code>df = pd.DataFrame({'subreddit': ['sub1', 'sub2', 'sub3', 'sub4'],
                     'user': [['A', 'B', 'C'], ['A', 'F', 'C'], ['F', 'E', 'D'], ['X', 'Y', 'Z']]})
  </code></pre>
  
  <p>Output for first subreddit:</p>
  
  <pre><code>subreddit_1 subreddit_2 shared_users
  sub1    sub2    2
  sub1    sub3    0
  sub1    sub4    0
  </code></pre>