title: How to create a view of dataframe in pandas?
body: <p>I have a large dataframe (10m rows, 40 columns, 7GB in memory). I would like to create a view in order to have a shorthand name for a view that is complicated to express, without adding another 2-4 GB to memory usage. In other words, I would rather type:</p>
  
  <pre><code>df2
  </code></pre>
  
  <p>Than:</p>
  
  <pre><code>df.loc[complicated_condition, some_columns]
  </code></pre>
  
  <p>The <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#why-does-assignment-fail-when-using-chained-indexing" rel="noreferrer">documentation</a> states that, while using <code>.loc</code> ensures that setting values modifies the original dataframe, there is still no guarantee as to whether the object returned by <code>.loc</code> is a view or a copy.</p>
  
  <p>I know I could assign the condition and column list to variables (e.g. <code>df.loc[cond, cols]</code>), but I'm generally curious to know whether it is possible to create a view of a dataframe.</p>
  
  <hr>
  
  <p><strong>Edit</strong>: Related questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/23296282/5276797">What rules does Pandas use to generate a view vs a copy?</a></li>
  <li><a href="https://stackoverflow.com/q/17960511/5276797">Pandas: Subindexing dataframes: Copies vs views</a></li>
  </ul>