diff --git a/plotnine/coords/coord.py b/plotnine/coords/coord.py index c7517edf1..8764eb53c 100644 --- a/plotnine/coords/coord.py +++ b/plotnine/coords/coord.py @@ -204,7 +204,6 @@ def munch_data(data, dist): len(data)-1]) munched = data.loc[idx, data.columns.difference(['x', 'y'])] - munched.is_copy = None munched['x'] = x munched['y'] = y munched.reset_index(drop=True, inplace=True) diff --git a/plotnine/geoms/geom.py b/plotnine/geoms/geom.py index 3bf71e852..d9cfc8d10 100644 --- a/plotnine/geoms/geom.py +++ b/plotnine/geoms/geom.py @@ -219,7 +219,6 @@ def draw_layer(self, data, layout, coord, **params): for pid, pdata in data.groupby('PANEL'): if len(pdata) == 0: continue - pdata.is_copy = None ploc = pid - 1 panel_params = layout.panel_params[ploc] ax = layout.axs[ploc] @@ -258,7 +257,6 @@ def draw_panel(self, data, panel_params, coord, ax, **params): """ for _, gdata in data.groupby('group'): gdata.reset_index(inplace=True, drop=True) - gdata.is_copy = None self.draw_group(gdata, panel_params, coord, ax, **params) @staticmethod diff --git a/plotnine/geoms/geom_abline.py b/plotnine/geoms/geom_abline.py index 4e1cbbdf7..6057a4300 100644 --- a/plotnine/geoms/geom_abline.py +++ b/plotnine/geoms/geom_abline.py @@ -62,6 +62,5 @@ def draw_panel(self, data, panel_params, coord, ax, **params): for _, gdata in data.groupby('group'): gdata.reset_index(inplace=True) - gdata.is_copy = None geom_segment.draw_group(gdata, panel_params, coord, ax, **params) diff --git a/plotnine/geoms/geom_dotplot.py b/plotnine/geoms/geom_dotplot.py index 0314a3f6f..0967522f6 100644 --- a/plotnine/geoms/geom_dotplot.py +++ b/plotnine/geoms/geom_dotplot.py @@ -92,7 +92,6 @@ def stackdots(a): for j in range(int(c))] data = data.iloc[idx] data.reset_index(inplace=True, drop=True) - data.is_copy = None # Next part will set the position of each dot within each stack # If stackgroups=TRUE, split only on x (or y) and panel; # if not stacking, also split by group diff --git a/plotnine/geoms/geom_hline.py b/plotnine/geoms/geom_hline.py index 508ec43c7..078ae3ba8 100644 --- a/plotnine/geoms/geom_hline.py +++ b/plotnine/geoms/geom_hline.py @@ -51,6 +51,5 @@ def draw_panel(self, data, panel_params, coord, ax, **params): for _, gdata in data.groupby('group'): gdata.reset_index(inplace=True) - gdata.is_copy = None geom_segment.draw_group(gdata, panel_params, coord, ax, **params) diff --git a/plotnine/geoms/geom_path.py b/plotnine/geoms/geom_path.py index acf3b4e0a..fc056597f 100644 --- a/plotnine/geoms/geom_path.py +++ b/plotnine/geoms/geom_path.py @@ -89,7 +89,6 @@ def draw_panel(self, data, panel_params, coord, ax, **params): c = Counter(data['group']) counts = np.array([c[v] for v in data['group']]) data = data[counts >= 2] - data.is_copy = None if len(data) < 2: return @@ -108,7 +107,6 @@ def draw_panel(self, data, panel_params, coord, ax, **params): else: for _, gdata in data.groupby('group'): gdata.reset_index(inplace=True, drop=True) - gdata.is_copy = None self.draw_group(gdata, panel_params, coord, ax, **params) @staticmethod diff --git a/plotnine/geoms/geom_point.py b/plotnine/geoms/geom_point.py index b7763ab8a..874331b9f 100644 --- a/plotnine/geoms/geom_point.py +++ b/plotnine/geoms/geom_point.py @@ -31,7 +31,6 @@ def draw_group(data, panel_params, coord, ax, **params): data = coord.transform(data, panel_params) units = 'shape' for _, udata in groupby_with_null(data, units): - udata.is_copy = None udata.reset_index(inplace=True, drop=True) geom_point.draw_unit(udata, panel_params, coord, ax, **params) diff --git a/plotnine/geoms/geom_ribbon.py b/plotnine/geoms/geom_ribbon.py index 2336931e8..581328b31 100644 --- a/plotnine/geoms/geom_ribbon.py +++ b/plotnine/geoms/geom_ribbon.py @@ -39,7 +39,6 @@ def draw_group(data, panel_params, coord, ax, **params): raise PlotnineError(msg) for _, udata in groupby_with_null(data, units): - udata.is_copy = None udata.reset_index(inplace=True, drop=True) geom_ribbon.draw_unit(udata, panel_params, coord, ax, **params) diff --git a/plotnine/geoms/geom_violin.py b/plotnine/geoms/geom_violin.py index 69c90030b..b33ef326e 100644 --- a/plotnine/geoms/geom_violin.py +++ b/plotnine/geoms/geom_violin.py @@ -53,8 +53,6 @@ def draw_panel(self, data, panel_params, coord, ax, **params): quantiles = params['draw_quantiles'] for _, df in data.groupby('group'): - df.is_copy = None - # Find the points for the line to go all the way around df['xminv'] = (df['x'] - df['violinwidth'] * (df['x'] - df['xmin'])) diff --git a/plotnine/geoms/geom_vline.py b/plotnine/geoms/geom_vline.py index 90a989817..b146c03b1 100644 --- a/plotnine/geoms/geom_vline.py +++ b/plotnine/geoms/geom_vline.py @@ -51,7 +51,6 @@ def draw_panel(self, data, panel_params, coord, ax, **params): for _, gdata in data.groupby('group'): gdata.reset_index(inplace=True) - gdata.is_copy = None geom_segment.draw_group(gdata, panel_params, coord, ax, **params) diff --git a/plotnine/ggplot.py b/plotnine/ggplot.py index 7723338d3..ee3647ac8 100644 --- a/plotnine/ggplot.py +++ b/plotnine/ggplot.py @@ -181,6 +181,13 @@ def draw(self, return_ggplot=False): This method does not modify the original ggplot object. You can get the modified ggplot object with :py:`return_ggplot=True`. """ + # Pandas deprecated is_copy, and when we create new dataframes + # from slices we do not want complaints. We always uses the + # new frames knowing that they are separate from the original. + with pd.option_context('mode.chained_assignment', None): + return self._draw(return_ggplot) + + def _draw(self, return_ggplot=False): # Prevent against any modifications to the users # ggplot object. Do the copy here as we may/may not # assign a default theme diff --git a/plotnine/guides/guide_legend.py b/plotnine/guides/guide_legend.py index 1fb320c23..2069867e6 100644 --- a/plotnine/guides/guide_legend.py +++ b/plotnine/guides/guide_legend.py @@ -311,7 +311,6 @@ def draw(self): # overlay geoms for gl in self.glayers: data = gl.data.iloc[i] - data.is_copy = None da = gl.geom.draw_legend(data, da, gl.layer) drawings.append(da) themeable['legend_key'].append(drawings) diff --git a/plotnine/positions/position_stack.py b/plotnine/positions/position_stack.py index 39619d0ea..98dbb7926 100644 --- a/plotnine/positions/position_stack.py +++ b/plotnine/positions/position_stack.py @@ -70,8 +70,6 @@ def compute_panel(cls, data, scales, params): negative = data['ymax'] < 0 neg = data.loc[negative] pos = data.loc[~negative] - neg.is_copy = None - pos.is_copy = None if len(neg): neg = cls.collide(neg, params=params) diff --git a/plotnine/stats/stat.py b/plotnine/stats/stat.py index 8b0809a83..f6f5da486 100644 --- a/plotnine/stats/stat.py +++ b/plotnine/stats/stat.py @@ -299,7 +299,6 @@ def compute_panel(cls, data, scales, **params): stats = [] for _, old in data.groupby('group'): - old.is_copy = None new = cls.compute_group(old, scales, **params) unique = uniquecols(old) missing = unique.columns.difference(new.columns) diff --git a/plotnine/stats/stat_bindot.py b/plotnine/stats/stat_bindot.py index fd6438007..eb640c025 100644 --- a/plotnine/stats/stat_bindot.py +++ b/plotnine/stats/stat_bindot.py @@ -198,7 +198,6 @@ def func(df): if params['drop']: data = data[data['count'] > 0] data.reset_index(inplace=True, drop=True) - data.is_copy = None if params['binaxis'] == 'x': data['x'] = data.pop('bincenter') diff --git a/plotnine/stats/stat_smooth.py b/plotnine/stats/stat_smooth.py index 4a2e68f45..ab9d98d58 100644 --- a/plotnine/stats/stat_smooth.py +++ b/plotnine/stats/stat_smooth.py @@ -142,7 +142,6 @@ def setup_data(self, data): """ data = data[np.isfinite(data['x']) & np.isfinite(data['y'])] - data.is_copy = None return data def setup_params(self, data): diff --git a/plotnine/utils.py b/plotnine/utils.py index d590e79a5..a924b7a50 100644 --- a/plotnine/utils.py +++ b/plotnine/utils.py @@ -610,7 +610,6 @@ def groupby_apply(df, cols, func, *args, **kwargs): for _, d in df.groupby(cols): # function fn should be free to modify dataframe d, therefore # do not mark d as a slice of df i.e no SettingWithCopyWarning - d.is_copy = None lst.append(func(d, *args, **kwargs)) return pd.concat(lst, axis=axis, ignore_index=True) @@ -645,7 +644,6 @@ def groupby_with_null(data, *args, **kwargs): # Groupby on the columns, making sure to revert back # to NaN/None and the correct dtype. for group, df in data.groupby(*args, **kwargs): - df.is_copy = None for col, (orig_idx, orig_dtype) in altered_columns.items(): # Indices in the grouped df that need correction sub_idx = orig_idx.intersection(df[col].index)