title: Pandas create empty DataFrame with only column names
body: <p>I have a dynamic DataFrame which works fine, but when there are no data to be added into the DataFrame I get an error. And therefore I need a solution to create an empty DataFrame with only the column names.</p>
  
  <p>For now I have something like this:</p>
  
  <pre><code>df = pd.DataFrame(columns=COLUMN_NAMES) # Note that there are now row data inserted.
  </code></pre>
  
  <p>PS: It is important that the column names would still appear in a DataFrame.</p>
  
  <p>But when I use it like this I get something like that as a result:</p>
  
  <pre><code>Index([], dtype='object')
  Empty DataFrame
  </code></pre>
  
  <p>The "Empty DataFrame" part is good! But instead of the Index thing I need to still display the columns.</p>
  
  <p>Edit:</p>
  
  <p>An important thing that I found out: I am converting this DataFrame to a PDF using Jinja2, so therefore I'm calling out a method to first output it to HTML like that:</p>
  
  <pre><code>df.to_html()
  </code></pre>
  
  <p>This is where the columns get lost I think.</p>
  
  <p>Edit2:
  In general, I followed this example: <a href="http://pbpython.com/pdf-reports.html" rel="noreferrer">http://pbpython.com/pdf-reports.html</a>. The css is also from the link.
  That's what I do to send the dataframe to the PDF:</p>
  
  <pre><code>env = Environment(loader=FileSystemLoader('.'))
  template = env.get_template("pdf_report_template.html")
  template_vars = {"my_dataframe": df.to_html()}
  
  html_out = template.render(template_vars)
  HTML(string=html_out).write_pdf("my_pdf.pdf", stylesheets=["pdf_report_style.css"])
  </code></pre>
  
  <p>Edit3:</p>
  
  <p>If I print out the dataframe right after creation I get the followin:</p>
  
  <pre><code>[0 rows x 9 columns]
  Empty DataFrame
  Columns: [column_a, column_b, column_c, column_d, 
  column_e, column_f, column_g, 
  column_h, column_i]
  Index: []
  </code></pre>
  
  <p>That seems reasonable, but if I print out the template_vars:</p>
  
  <pre><code>'my_dataframe': '&lt;table border="1" class="dataframe"&gt;\n  &lt;tbody&gt;\n    &lt;tr&gt;\n      &lt;td&gt;Index([], dtype=\'object\')&lt;/td&gt;\n      &lt;td&gt;Empty DataFrame&lt;/td&gt;\n    &lt;/tr&gt;\n  &lt;/tbody&gt;\n&lt;/table&gt;'
  </code></pre>
  
  <p>And it seems that the columns are missing already.</p>
  
  <p>E4:
  If I print out the following:</p>
  
  <pre><code>print(df.to_html())
  </code></pre>
  
  <p>I get the following result already:</p>
  
  <pre><code>&lt;table border="1" class="dataframe"&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;Index([], dtype='object')&lt;/td&gt;
        &lt;td&gt;Empty DataFrame&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>