title: What is the equivalent of writerow() from csv module in pandas?
body: <p>I am currently making different functions for a script and I have a function that works perfectly with <code>writerow()</code> however for my other function I used pandas and I am trying to look for the equivalent of that. Im pretty sure <code>to_csv</code> is not what I want.</p>
  
  <p>Here is the same CSV that is being tested on both functions. </p>
  
  <pre><code>jeffrey,192.168.1.1,example1.com,30220,internet serverice provider 1
  mike,192.168.1.2,example2.com,30220,internet service provider 1
  frank,192.168.1.3,example3.com,30220,internet service provider 1
  lucy,192.168.1.4,example4.com,14619,internet service provider 2
  louisa,192.168.1.5,example5.com,14619,internet service provider 2
  emily,192.168.1.6,example6.com,3357,internet service provider 3 
  john,192.168.1.7,example7.com,210,internet service provider 4
  </code></pre>
  
  <p>Here is my script that works for <code>writerow()</code></p>
  
  <pre><code>import csv
  
  document= open("sample.csv")
  
  def start_yes():
      with open ('good_numbers', 'w') as output:
          with document as file:
              output_data = csv.writer(output, delimiter = ',')
              reader = csv.reader(file)
              list_1 = ['3357','210']
              for row in reader:
                  if row[3] in list_1:
                      output_data.writerow(row)
  </code></pre>
  
  <p>Running this script with the sample.csv provides me the results like this, which is what I want.</p>
  
  <pre><code>emily,192.168.1.6,example6.com,3357,internet service provider 3 
  john,192.168.1.7,example7.com,210,internet service provider 4
  </code></pre>
  
  <p>Here is the script that I am trying to find the equivalent of <code>writerow()</code> however using the pandas module.</p>
  
  <pre><code>import pandas as pd 
  
  df = pd.read_csv('sample.csv', header=None)
  good_nums = ['3357','210']
  bad_nums = ['30220']
  maybe_nums = list(set(df[3].tolist()) - set(good_nums + bad_nums))
  for asn in df: 
      if asn in df[3]:
      asn.to_csv('output.csv', index=False)
  </code></pre>
  
  <p>How can I get my result looking like this with the script that uses pandas</p>
  
  <pre><code>lucy,192.168.1.4,example4.com,14619,internet service provider 2
  louisa,192.168.1.5,example5.com,14619,internet service provider 2
  </code></pre>
  
  <p>Any help is greatly appreciated! </p>