title: How to select ONLY THE INDEX COLUMNS in a pandas multi-index Dataframe?
body: <p>Okay, so I have a DataFrame with a 2 column index, and I am trying to filter the rows from that DataFrame and keep ONLY THE INDEX COLUMNS of the original dataframe into the new filtered DataFrame.</p>
  
  <p>I created the dataframe from a CSV file by: Find the CSV file <a href="https://drive.google.com/open?id=1S5aaJ4uX6XUBzSz3lYZdS5owuBq3FbZa" rel="nofollow noreferrer">here</a></p>
  
  <pre><code>census_df = pd.read_csv("census.csv", index_col = ["STNAME", "CTYNAME"])
  census_df.sort_index(ascending = True)
  </code></pre>
  
  <p>Then, I applied some filtering to the DataFrame, which works perfectly fine, and I get the desired rows. The code I used is shown below:</p>
  
  <pre><code>def my_answer():
  
      mask1 = census_df["REGION"].between(1, 2)
      mask2 = census_df.index.get_level_values("CTYNAME").str.startswith("Washington")
      mask3 = (census_df["POPESTIMATE2015"] &gt; census_df["POPESTIMATE2014"])
      new_df = census_df[mask1 &amp; mask2 &amp; mask3]
      return pd.DataFrame(new_df.iloc[:, -1])
  
  my_answer()
  </code></pre>
  
  <p>Here is the problem:</p>
  
  <p>The above code returns a dataframe with the index AND the first column IN ADDITION to the 2 index columns. What I want is JUST THE TWO INDEX COLUMNS. 
  So, the final answer should return a DATAFRAME, with "STNAME" and "CTYNAME", with 5 rows in it. </p>