title: Can't clear pandas dataframe
body: <p>This is my first time using pandas and I am trying to make a forloop that extracts mp3 links from a website and put them into a csv file. For each album link, it will make a new folder and a new csv file, then it will put the mp3s into the csv.</p>
  <p>Everything works <strong>BUT</strong> I have one major problem - The dataframe keeps appending the data from the last loop into the current loop. So my dataframe's <code>list</code> keeps getting bigger and bigger.</p>
  <p>Here is what the code looks like:</p>
  <pre><code>from bs4 import BeautifulSoup
  import urllib.request
  import re
  import pandas as pd
  import os
  import csv
  
  def mpull():
     albumlist()
     baseurl = &quot;https://downloads.khinsider.com&quot;
     alist = albumlist.albums_str
     llist = albumlist.link_str
     fullsoup = []
     for l, ab in zip(llist, alist):
        os.mkdir(ab)
        url = urllib.request.urlopen(l)
        content = url.read()
        soup = BeautifulSoup(content, features=&quot;html.parser&quot;)
        for a in soup.findAll('a',href=re.compile('/*\.mp3')):
           df = pd.DataFrame([])
           fullsoup.append(baseurl+a['href'])
           remove_dup(fullsoup)
           df = pd.DataFrame(fullsoup)
        df.to_csv(ab+&quot;/&quot;+ab+&quot;.csv&quot;, index=False, header=False) 
        print(fullsoup)
  mpull()
  
  </code></pre>
  <p>What I want is this:</p>
  <pre><code>007 everything or nothing:
  
  https://downloads.khinsider.com/game-soundtracks/album/007-everything-or-nothing/EON-01-James-Bond-Theme.mp3
  https://downloads.khinsider.com/game-soundtracks/album/007-everything-or-nothing/EON-02-Russian-Liar.mp3
  #MORE 007 everything or nothing songs
  </code></pre>
  <p>What I am getting is this:</p>
  <pre><code>007 everything or nothing:
  #songs from the last loop appear first for some reason
  https://downloads.khinsider.com/game-soundtracks/album/007-blood-stone/01-%2520James%2520Bond-Blood%2520Stone%2520Theme%2520Song.mp3
  https://downloads.khinsider.com/game-soundtracks/album/007-blood-stone/02-%2520M%2520Puts%2520Her%2520Trust%2520in%2520Bond.mp3
  #Then the right songs appear afterwards 
  https://downloads.khinsider.com/game-soundtracks/album/007-everything-or-nothing/EON-01-James-Bond-Theme.mp3
  https://downloads.khinsider.com/game-soundtracks/album/007-everything-or-nothing/EON-02-Russian-Liar.mp3
  #MORE 007 everything or nothing songs
  </code></pre>
  <p>What I tried:
  I tried adding <code>del df</code> to the end of the loop like so:</p>
  <pre><code>from bs4 import BeautifulSoup
  import urllib.request
  import re
  import pandas as pd
  import os
  import csv
  
  def mpull():
     albumlist()
     baseurl = &quot;https://downloads.khinsider.com&quot;
     alist = albumlist.albums_str
     llist = albumlist.link_str
     fullsoup = []
     for l, ab in zip(llist, alist):
        os.mkdir(ab)
        url = urllib.request.urlopen(l)
        content = url.read()
        soup = BeautifulSoup(content, features=&quot;html.parser&quot;)
        for a in soup.findAll('a',href=re.compile('/*\.mp3')):
           df = pd.DataFrame([])
           fullsoup.append(baseurl+a['href'])
           remove_dup(fullsoup)
           df = pd.DataFrame(fullsoup)
        df.to_csv(ab+&quot;/&quot;+ab+&quot;.csv&quot;, index=False, header=False) 
        del def
        print(fullsoup)
  mpull()
  </code></pre>
  <p>But that didn't seem to do anything or rather - it was still appending the last loop's dataframe into the current csv iteration.</p>
  <p>Any ideas would be awesome. Thanks!</p>