title: How to write to a specific cell in excel using Pandas?
body: <p>I am coding below steps in Python and need to correct code to write a value to specific cell in excel.</p>
  
  <ol>
  <li>Read sql from specific cell in excel e.g. B1</li>
  <li>make db connection and run sql </li>
  <li>Store/write the Sql output to Result Column. e.g. C1</li>
  </ol>
  
  <p>TestResult excel Sheet:</p>
  
  <p><a href="https://i.stack.imgur.com/cAU8h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cAU8h.png" alt="enter image description here"></a></p>
  
  <p>Code</p>
  
  <pre><code>import pandas
  #1
  result_df = pandas.read_excel("P:\TestResultSheet.xlsx", "TestResult")
  sqlRun = result_df.query("Jira_Num == 'XXXX-01' ")["TestQuery"]
  #2 : Got sql output e.g. 110,000
  #3 
  result_df.loc[sqlRun.index, "ActualResult"] = 110,000
  result_df.to_excel("P:\TestResultSheet.xlsx", "TestResult") 
  </code></pre>
  
  <p>Above code is not writing to existing column ActualResult and creating another columns with same name and writing result as (also this is deleting other sheets):</p>
  
  <pre><code>result_df
  
       Jira_Num TestQuery                   ActualResult ActualResult
  0    XXXX-01     Seelct count (*) from XYZ    NaN         110,000
  </code></pre>