I guess your eG
DF is a copy of another DF...
Here is a small demo:
In [69]: df = pd.DataFrame(np.random.randint(0, 5, (10, 3)), columns=list('abc'))
In [70]: cp = df[df.a > 0]
In [71]: cp.loc[:, 'c'] = cp.groupby('a').b.transform('sum')
c:\envs\py35\lib\site-packages\pandas\core\indexing.py:549: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
self.obj[item_labels[indexer[info_axis]]] = value
Workaround:
In [72]: cp = df[df.a > 0].copy()
In [73]: cp.loc[:, 'c'] = cp.groupby('a').b.transform('sum')
Or if you don't need original DF you can save memory:
In [74]: df = df[df.a > 0]
In [75]: df.loc[:, 'c'] = df.groupby('a').b.transform('sum')