title: Use fitsio to rename a FITS file extension in Python
body: <p>I am using the fitsio library trying to create a new fits file, insert a table from a dataframe df, and change a keyword. However, when I do that, my first extension has no name. I cannot figure out how to change the extension name.
  Right now I am doing the following:</p>
  <pre><code>import fitsio
  
  example_file = fitsio.FITS('example_test.fits', 'rw')
  example_file.write(df.to_records(index=False))
  
  example_file[1].write_key('My Key Name', key_name, comment=&quot;seconds&quot;)
  example_file.close()
  </code></pre>