<p dir="auto">Hello,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#!/bin/env python
import pandas as pd
import numpy as np
import sys
print sys.version
print &quot;NUMPY:&quot;, np.__version__
print &quot;PANDAS:&quot;, pd.__version__

df = pd.DataFrame([[0, None], [4, 3]], columns=['a','b'])
print df

df[&quot;c&quot;] = 1.0
#print df #uncomment and result change

df[&quot;c&quot;][~df.all(axis=1)] = 2
print df
print df.c"><pre class="notranslate"><code class="notranslate">#!/bin/env python
import pandas as pd
import numpy as np
import sys
print sys.version
print "NUMPY:", np.__version__
print "PANDAS:", pd.__version__

df = pd.DataFrame([[0, None], [4, 3]], columns=['a','b'])
print df

df["c"] = 1.0
#print df #uncomment and result change

df["c"][~df.all(axis=1)] = 2
print df
print df.c
</code></pre></div>
<p dir="auto">gives</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.7.2 (default, Jul 30 2012, 17:32:47)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
NUMPY: 1.7.1
PANDAS: 0.12.0
   a   b
0  0 NaN
1  4   3
   a   b  c
0  0 NaN  1
1  4   3  1
0    2
1    1
Name: c, dtype: float64"><pre class="notranslate"><code class="notranslate">2.7.2 (default, Jul 30 2012, 17:32:47)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
NUMPY: 1.7.1
PANDAS: 0.12.0
   a   b
0  0 NaN
1  4   3
   a   b  c
0  0 NaN  1
1  4   3  1
0    2
1    1
Name: c, dtype: float64
</code></pre></div>
<p dir="auto">As you can see, I try to change value of the c columns to "2" for the element where one of the column is null and it does not work.</p>
<p dir="auto">The serie is however modified.<br>
What is even stranger is that adding an intermediate print (uncomment above) changes the behavior.</p>
<p dir="auto">I was not able to find any duplicate of this issue.<br>
Thanks in advance for having a look.</p>
<p dir="auto">Extend the new "pipe" protocol to GroupBy objects to allow for piping of a wider class of functions.  Currently, one can only create pipes that chain together objects inheriting from NDFrame.  But the concept of piping is general and could be extended to other pandas objects, specifically anything inheriting from GroupBy.</p>
<p dir="auto">The use case is to write pipe that allow one to freely transform back-and-forth between NDFrames and GroupBy objects.  Example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df = DataFrame({A: [...], B: [...]})

def f(dfgb):
    return dfgb['B'].value_counts()

def g(srs):
    return srs * 2

grouped = df.groupby('A')

grouped.pipe(f).pipe(g)"><pre class="notranslate"><code class="notranslate">df = DataFrame({A: [...], B: [...]})

def f(dfgb):
    return dfgb['B'].value_counts()

def g(srs):
    return srs * 2

grouped = df.groupby('A')

grouped.pipe(f).pipe(g)
</code></pre></div>
<p dir="auto">Note that these transformations are transformations are</p>
<ul dir="auto">
<li>GroupBy -&gt; Series</li>
<li>Series -&gt; Series<br>
and the chain seamlessly switches from a GroupBy.pipe to a NDFrame.pipe</li>
</ul>
<p dir="auto">There are a few ways to implement this.  A simple way is to break out the core functionality of "pipe" into a pure function and then to call that function in any method implementation of pipe.  Another way is to think of piping as a mix-in trait, put it as a method in a base class, and then mix that base class into any class that wants to implement pipe-ability.  I have no strong preference between these options, and I'm open to other implementations that may be more inline with Pandas' design goals or the long-term vision of the "pipe" concept.</p>
<p dir="auto">A strawman implementation of the first implementation suggestion can be found here:<br>
<a class="commit-link" href="https://github.com/pandas-dev/pandas/compare/master...ghl3:groupby-pipe"><tt>master...ghl3:groupby-pipe</tt></a></p>
<p dir="auto">CC<br>
<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/TomAugspurger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/TomAugspurger">@TomAugspurger</a><br>
<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/shoyer/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/shoyer">@shoyer</a></p>