title: Is there a way to return a pandas dataframe with a modified column?
body: <p>Say I have a dataframe <code>df</code> with column <code>&quot;age&quot;</code>.
  Say <code>&quot;age&quot;</code> has some <code>NaN</code> values and I want to create two new dataframes, <code>dfMean</code> and <code>dfMedian</code>, which fill in the <code>NaN</code> values differently.
  This is the way I would do it:</p>
  <pre><code># Step 1:
  dfMean = df
  dfMean[&quot;age&quot;].fillna(df[&quot;age&quot;].mean(),inplace=True)
  # Step 2:
  dfMedian= df
  dfMedian[&quot;age&quot;].fillna(df[&quot;age&quot;].median(),inplace=True)
  </code></pre>
  <p>I'm curious whether there's a way to do each of these steps in one line instead of two, by returning the modified dataframe without needing to copy the original. But I haven't been able to find anything so far. Thanks, and let me know if I can clarify or if you have a better title in mind for the question :)</p>