title: Will changes in DataFrame.values always modify the values in the data frame?
body: <p>On the documentation, it says </p>
  
  <blockquote>
    <p>Numpy representation of NDFrame -- <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.values.html" rel="nofollow noreferrer">Source</a></p>
  </blockquote>
  
  <p>What does "Numpy representation of NDFrame" mean? Will modifying this numpy representation affect my original dataframe? In other words, <strong>will <code>.values</code> return a copy or a view</strong>?</p>
  
  <p>There are answers to questions in StackOverflow <strong>implicitly</strong> suggesting (<strong>relying on</strong>) that a view be returned. For example, in the accepted answer of <a href="https://stackoverflow.com/questions/24475094/set-values-on-the-diagonal-of-pandas-dataframe">Set values on the diagonal of pandas.DataFrame</a>,<code>np.fill_diagonal(df.values, 0)</code> is used to set all values on the diagonal part of <code>df</code> to 0. That is a view is returned in this case. However, as shown in <a href="https://stackoverflow.com/questions/48201521/will-changes-in-dataframe-values-always-modify-the-values-in-the-data-frame/48201760#48201760">@coldspeed's answer</a>, <strong>sometimes a copy is returned.</strong> </p>
  
  <p>This feels very basic. It is just a bit weird to me because I do not have a more detailed source of <code>.values</code>.</p>
  
  <hr>
  
  <p>Another experiment that returns a view in addition to the current experiments in @coldspeed's answer:</p>
  
  <pre><code>df = pd.DataFrame([["A", "B"],["C", "D"]])
  
  df.values[0][0] = 0
  </code></pre>
  
  <p>We get</p>
  
  <pre><code>df
      0   1
  0   0   B
  1   C   D
  </code></pre>
  
  <p>Even though it is mixed type now, we can still modify original <code>df</code> by setting <code>df.values</code></p>
  
  <pre><code>df.values[0][1] = 5
  df
      0   1
  0   0   5
  1   C   D
  </code></pre>