title: Change one element of column heading in CSV using Pandas
body: <p>I have created a CSV file which looks like this:</p>
  <blockquote>
  <p>RigName,Date,DrillingMiles,TrippingMiles,CasingMiles,LinerMiles,JarringMiles,TotalMiles,Comments<br />
  0,08 July 2021,19.21,63.05,43.16,45.41,8.52,0,&quot;Tested all totals. Edge cases for multiple clicks.
  &quot;<br />
  1,09 July 2021,19.21,63.05,43.16,45.41,8.52,0,&quot;Test entry#2.
  &quot;</p>
  </blockquote>
  <p>I wish to change the 'RigName' to something the user inputs. I have tried various ways of changing the word 'RigName' to user input. One of them is this:</p>
  <pre><code>df= pd.read_csv('ton_miles_record.csv')
  user_input = 'Rig805'
  df.columns = df.columns.str.replace('RigName', user_input)
  df.to_csv('new_csv.csv', header=True, index=False)
  </code></pre>
  <p>However no matter what I do, the result in the csv file always comes to this:</p>
  <blockquote>
  <p>Unnamed:0,Date,DrillingMiles,TrippingMiles,CasingMiles,LinerMiles,JarringMiles,TotalMiles,Comments</p>
  </blockquote>
  <p>Why am I getting 'Unnamed: 0' instead of the user input value?</p>
  <p>Also, is there a way to change 'RigName' to something else by calling its position? To make multiple changes to any word in its position in future?</p>