title: Python Iterate through rows, run and save
body: <p>I have a pandas dataframe where I want to loop over its rows, run and save output, if any error then ingore it and move to next row.</p>
  <pre><code>import pandas as pd
  from nsepy import get_history #can be install by &quot;pip install nsepy&quot;
  from datetime import date
  
  data = {'script': ['SBIN = get_history(symbol=&quot;SBIN&quot;, start=date(1985,1,1), end=date(2022,1,31))',
  'SAIL = get_history(symbol=&quot;SAIL&quot;, start=date(1985,1,1), end=date(2022,1,31))', 
  '20MICRONS = get_history(symbol=&quot;20MICRONS&quot;, start=date(1985,1,1), end=date(2022,1,31))',
  'RELIANCE = get_history(symbol=&quot;RELIANCE&quot;, start=date(1985,1,1), end=date(2022,1,31))']}  
  
  df = pd.DataFrame(data)  
  </code></pre>
  <p>Now I want to run each line one by one
  I can do it by</p>
  <pre><code>#run each row
  #1
  SBIN = get_history(symbol=&quot;SBIN&quot;, start=date(1985,1,1), end=date(2022,1,31))
  df1.to_csv('SBIN', sep=&quot;\t&quot;)
  #2
  SAIL = get_history(symbol=&quot;SAIL&quot;, start=date(1985,1,1), end=date(2022,1,31))'
  df1.to_csv('SAIL', sep=&quot;\t&quot;)
  #3
  20MICRONS = get_history(symbol=&quot;20MICRONS&quot;, start=date(1985,1,1), end=date(2022,1,31))
  df1.to_csv('20MICRONS', sep=&quot;\t&quot;)
  #4
  RELIANCE = get_history(symbol=&quot;RELIANCE&quot;, start=date(1985,1,1), end=date(2022,1,31))
  df1.to_csv('RELIANCE', sep=&quot;\t&quot;)
  </code></pre>
  <p>But it is going to take huge time. so how can it be done by for loop or while loop</p>
  <p>Please note I would like to run each row and save the output as a character extracted before = sign of same row for example &quot;SBIN&quot; for first row. In case if there is any error on any line then ignore the error and move to the next line (line 3 is going to return an error which is due to the unavailability of data)</p>