title: Deep copy of Pandas dataframes and dictionaries
body: <p>I'm creating a small Pandas dataframe:</p>
  
  <pre><code>df = pd.DataFrame(data={'colA': [["a", "b", "c"]]})
  </code></pre>
  
  <p>I take a deepcopy of that df. I'm not using the Pandas method but general Python, right? </p>
  
  <pre><code>import copy
  df_copy = copy.deepcopy(df)
  </code></pre>
  
  <p>A df_copy.head() gives the following: </p>
  
  <p><a href="https://i.stack.imgur.com/jP5DZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jP5DZ.png" alt="enter image description here"></a></p>
  
  <p>Then I put these values into a dictionary: </p>
  
  <pre><code>mydict = df_copy.to_dict()
  </code></pre>
  
  <p>That dictionary looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/7Fqgu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Fqgu.png" alt="enter image description here"></a></p>
  
  <p>Finally, I remove one item of the list:</p>
  
  <pre><code>mydict['colA'][0].remove("b")
  </code></pre>
  
  <p>I'm surprized that the values in df_copy are updated. I'm <strong>very confused</strong> that the values in the original dataframe are updated too! Both dataframes look like this now:</p>
  
  <p><a href="https://i.stack.imgur.com/GudAs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GudAs.png" alt="enter image description here"></a></p>
  
  <p>I understand Pandas doesn't really do deepcopy, but this wasn't a Pandas method. My questions are:</p>
  
  <p>1) how can I build a dictionary from a dataframe that doesn't update the dataframe?</p>
  
  <p>2) how can I take a copy of a dataframe which would be completely independent?</p>
  
  <p>thanks for your help!</p>
  
  <p>Cheers,
  Nicolas</p>