title: How to export a dataframe to excel with sheets based on values in a column
body: <p>I have created a data frame in Python based on marging multiple excel files, and now I would like to export that combined data to one .xlsx file with multiple sheets based on values in a column and have those sheets named after the value in the column.</p>
  
  <p>using examples from the images below, I can currently export all the data to an .xlsx file.</p>
  
  <p>What I would like to do is filter the data by the zone column, and export all the data associated with the Zone1 flag in the Zone column to a sheet named "Zone1" and all the data associated with the flag Zone2 to a sheet named "Zone2" . Ideally, in the second image, the highlighted data is the only data what would show up in the current "Zone1" Sheet, and the unhighlighted data would be in sheet "Zone2"</p>
  
  <p>I'm using the following code to pull in the data, merge, and export.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import glob
  
  glob.glob("/Users/xxx/Desktop/PythonTests/Test_Zone*.xlsx")
  
  all_data = pd.DataFrame()
  for f in     glob.glob("/Users/xxx/Desktop/PythonTests/Test_Zone*.xlsx"):
  df = pd.read_excel(f)
  all_data = all_data.append(df,ignore_index=True)
  all_data.to_excel("/Users/xxx/Desktop/merged.xlsx",index=False)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AFnJx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AFnJx.png" alt="What I currently can export"></a></p>
  
  <p><a href="https://i.stack.imgur.com/VQFWL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VQFWL.png" alt="What I&#39;d like to export"></a></p>