diff --git a/verticapy/__init__.py b/verticapy/__init__.py index 947cbe4f2..ba44a0e33 100755 --- a/verticapy/__init__.py +++ b/verticapy/__init__.py @@ -37,9 +37,9 @@ __url__: str = "https://github.com/vertica/verticapy/" __license__: str = "Apache License, Version 2.0" __version__: str = "1.1.0-beta" -__iteration__: int = 2 -__date__: str = "10032024" -__last_commit__: str = "c4fa73aaaf54051fb35b325a5dd77573ba9b3f4c" +__iteration__: int = 1 +__date__: str = "10042024" +__last_commit__: str = "b229f82d26eb61ddfc0375a7169e27a33f60340a" __long_version__: str = f"{__version__}-{__iteration__}—{__date__}-{__last_commit__}" __codecov__: float = 0.84 diff --git a/verticapy/_typing.py b/verticapy/_typing.py index 2dbb16cf7..aac6ac0cd 100755 --- a/verticapy/_typing.py +++ b/verticapy/_typing.py @@ -58,5 +58,7 @@ PlottingObject = Union[ "PlottingBase", "TableSample", "Axes", "mFigure", "Highchart", "Highstock", "Figure" ] -PlottingMethod = Union[Literal["density", "count", "avg", "min", "max", "sum"], str] +PlottingMethod = Union[ + Literal[None, "density", "count", "avg", "min", "max", "sum"], str +] ColorType = str diff --git a/verticapy/core/vdataframe/_fill.py b/verticapy/core/vdataframe/_fill.py index e22276786..c86cc58bc 100755 --- a/verticapy/core/vdataframe/_fill.py +++ b/verticapy/core/vdataframe/_fill.py @@ -868,7 +868,8 @@ def fillna( | ``vDataFrame.``:py:meth:`~verticapy.vDataFrame.interpolate` : Fill missing values by interpolating. | ``vDataColumn.``:py:meth:`~verticapy.vDataColumn.fill_outliers` : Fill the outliers using the input method. """ - method = method.lower() + if isinstance(method, str): + method = method.lower() by, order_by = format_type(by, order_by, dtype=list) by, order_by = self._parent.format_colnames(by, order_by) if method == "auto": diff --git a/verticapy/core/vdataframe/_plotting.py b/verticapy/core/vdataframe/_plotting.py index fd172c64c..509413e37 100755 --- a/verticapy/core/vdataframe/_plotting.py +++ b/verticapy/core/vdataframe/_plotting.py @@ -251,6 +251,10 @@ def bar( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. Parameter ``of`` + must not be empty, otherwise it + is ignored. It can also be a cutomized aggregation, for example: ``AVG(column1) + 5`` @@ -425,6 +429,14 @@ def bar( categoryorder=categoryorder, **style_kwargs, ) + elif len(columns) == 2 and isinstance(method, NoneType) and not (of): + return self[columns[0]].bar( + method=None, + of=columns[1], + max_cardinality=max_cardinality[0], + categoryorder=categoryorder, + **style_kwargs, + ) elif kind == "drilldown": vpy_plt, kwargs = self.get_plotting_lib( class_name="DrillDownBarChart", @@ -529,6 +541,10 @@ def barh( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. Parameter ``of`` + must not be empty, otherwise it + is ignored. It can also be a cutomized aggregation, for example: ``AVG(column1) + 5`` @@ -706,6 +722,14 @@ def barh( categoryorder=categoryorder, **style_kwargs, ) + elif len(columns) == 2 and isinstance(method, NoneType) and not (of): + return self[columns[0]].barh( + method=None, + of=columns[1], + max_cardinality=max_cardinality[0], + categoryorder=categoryorder, + **style_kwargs, + ) elif kind == "drilldown": vpy_plt, kwargs = self.get_plotting_lib( class_name="DrillDownHorizontalBarChart", @@ -2163,6 +2187,11 @@ def hexbin( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. Parameter ``of`` + must not be empty, otherwise it + is ignored. The function to draw + the final chart will be ``max```. of: str, optional The vDataColumn used to compute the aggregation. @@ -2221,7 +2250,7 @@ def hexbin( } ) - Below is an examples of one type of hexbin plots: + Below is an example of one type of hexbin plots: - Hexbin @@ -2805,9 +2834,9 @@ def numh( fd = max( 2.0 * (vDataColumn_075 - vDataColumn_025) / (count) ** (1.0 / 3.0), 1e-99 ) - if method.lower() == "sturges": + if str(method).lower() == "sturges": best_h = sturges - elif method.lower() in ("freedman_diaconis", "fd"): + elif str(method).lower() in ("freedman_diaconis", "fd"): best_h = fd else: best_h = max(sturges, fd) @@ -3001,6 +3030,8 @@ def bar( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. It can also be a cutomized aggregation (ex: AVG(column1) + 5). @@ -3122,7 +3153,7 @@ def bar( @save_verticapy_logs def barh( self, - method: str = "density", + method: PlottingMethod = "density", of: Optional[str] = None, max_cardinality: int = 6, nbins: int = 0, @@ -3168,6 +3199,8 @@ def barh( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. It can also be a cutomized aggregation (ex: AVG(column1) + 5). @@ -3289,7 +3322,7 @@ def barh( @save_verticapy_logs def pie( self, - method: str = "density", + method: PlottingMethod = "density", of: Optional[str] = None, max_cardinality: int = 6, h: PythonNumber = 0, @@ -3333,6 +3366,8 @@ def pie( q Quantile of the :py:class:`~vDataColumns` ``of`` (ex: 50% to get the median). + - None: + No Aggregations. It can also be a cutomized aggregation (ex: ``AVG(column1) + 5``). @@ -3452,7 +3487,7 @@ def pie( def spider( self, by: Optional[str] = None, - method: str = "density", + method: PlottingMethod = "density", of: Optional[str] = None, max_cardinality: tuple[int, int] = (6, 6), h: tuple[PythonNumber, PythonNumber] = (None, None), @@ -3592,7 +3627,7 @@ def spider( def hist( self, by: Optional[str] = None, - method: str = "density", + method: PlottingMethod = "density", of: Optional[str] = None, h: Optional[PythonNumber] = None, h_by: PythonNumber = 0, @@ -3935,7 +3970,7 @@ def density( def candlestick( self, ts: str, - method: str = "sum", + method: PlottingMethod = "sum", q: tuple[float, float] = (0.25, 0.75), start_date: Optional[PythonScalar] = None, end_date: Optional[PythonScalar] = None, @@ -4020,6 +4055,12 @@ def candlestick( import numpy as np + We can create a variable ``N`` to fix the size: + + .. ipython:: python + + N = 30 + Let's generate a dataset using the following data. .. ipython:: python @@ -4037,7 +4078,6 @@ def candlestick( data["population"].candlestick(ts = "date") - .. ipython:: python :suppress: :okwarning: diff --git a/verticapy/core/vdataframe/_sys.py b/verticapy/core/vdataframe/_sys.py index f36599322..6c9c2c49d 100755 --- a/verticapy/core/vdataframe/_sys.py +++ b/verticapy/core/vdataframe/_sys.py @@ -210,7 +210,7 @@ def _get_catalog_value( return "VERTICAPY_NOT_PRECOMPUTED" return total elif method: - method = verticapy_agg_name(method.lower()) + method = verticapy_agg_name(str(method).lower()) if columns[1] in self[columns[0]]._catalog[method]: return self[columns[0]]._catalog[method][columns[1]] else: @@ -1317,10 +1317,14 @@ def store_usage(self) -> int: ) return store_usage - def rename(self, new_name: str) -> "vDataFrame": + def rename( + self, + new_name: str, + inplace: bool = True, + ) -> "vDataFrame": """ - Renames the vDataColumn by dropping the current vDataColumn - and creating a copy with the specified name. + Renames the vDataColumn. This function is not + directly applied to the input object. .. warning:: @@ -1328,16 +1332,24 @@ def rename(self, new_name: str) -> "vDataFrame": vDataFrame has been transformed multiple times, so it's better practice to use this method when first preparing your data. + It is even recommended to use directly + ``vDataFrame.``:py:meth:`~verticapy.vDataFrame.select` + method and do all the renaming within + one single operation. Parameters ---------- new_name: str The new vDataColumn alias. + inplace: bool, optional + If set to ``True``, the + :py:class:`~vDataFrame` is replaced + with the new relation. Returns ------- vDataFrame - self._parent + result. Examples -------- @@ -1385,8 +1397,7 @@ def rename(self, new_name: str) -> "vDataFrame": .. ipython:: python :suppress: - vdf["val"].rename("value") - result = vdf + result = vdf["val"].rename("value", inplace=False) html_file = open("SPHINX_DIRECTORY/figures/core_vDataFrame_sys_rename.html", "w") html_file.write(result._repr_html_()) html_file.close() @@ -1407,9 +1418,11 @@ def rename(self, new_name: str) -> "vDataFrame": "By changing the parameter 'new_name', you'll " "be able to solve this issue." ) - self._parent.eval(name=new_name, expr=old_name) - parent = self.drop(add_history=False) - parent._add_to_history( - f"[Rename]: The vDataColumn {old_name} was renamed '{new_name}'." + res = self._parent.select( + self._parent.get_columns(exclude_columns=[old_name]) + + [f"{old_name} AS {new_name}"] ) - return parent + if inplace: + self._parent.__init__(res.current_relation()) + return self._parent + return res diff --git a/verticapy/plotting/_matplotlib/bar.py b/verticapy/plotting/_matplotlib/bar.py index 9ab49c184..7b8bd1836 100755 --- a/verticapy/plotting/_matplotlib/bar.py +++ b/verticapy/plotting/_matplotlib/bar.py @@ -78,7 +78,7 @@ def draw( xticks_label = xticks ax.set_xticks(xticks) ax.set_xticklabels(xticks_label, rotation=90) - ax.set_ylabel(self.layout["method"]) + ax.set_ylabel(self.layout["method_of"]) return ax @@ -151,7 +151,7 @@ def draw( ax.set_xticks(xticks) ax.set_xticklabels(self.layout["x_labels"], rotation=90) ax.set_xlabel(self.layout["columns"][0]) - ax.set_ylabel(self.layout["method"]) + ax.set_ylabel(self.layout["method_of"]) ax.legend( title=self.layout["columns"][1], loc="center left", bbox_to_anchor=[1, 0.5] ) diff --git a/verticapy/plotting/_matplotlib/barh.py b/verticapy/plotting/_matplotlib/barh.py index 89e469e27..9af990bc3 100755 --- a/verticapy/plotting/_matplotlib/barh.py +++ b/verticapy/plotting/_matplotlib/barh.py @@ -76,7 +76,7 @@ def draw( ax.set_yticks( [x - round(self.data["width"] / 2, 10) for x in self.data["x"]] ) - ax.set_xlabel(self.layout["method"]) + ax.set_xlabel(self.layout["method_of"]) return ax @@ -187,7 +187,7 @@ def draw( ax.set_yticks(yticks) ax.set_yticklabels(self.layout["x_labels"]) ax.set_ylabel(self.layout["columns"][0]) - ax.set_xlabel(self.layout["method"]) + ax.set_xlabel(self.layout["method_of"]) if self.layout["kind"] in ("density", "fully_stacked"): vals = ax.get_xticks() max_val = max(abs(x) for x in vals) diff --git a/verticapy/plotting/_matplotlib/pie.py b/verticapy/plotting/_matplotlib/pie.py index dd72a0737..21936c3b0 100755 --- a/verticapy/plotting/_matplotlib/pie.py +++ b/verticapy/plotting/_matplotlib/pie.py @@ -112,11 +112,11 @@ def draw( ): current_explode = min(0.9, current_explode * 1.4) explode[idx] = current_explode - if self.layout["method"].lower() == "density": + if str(self.layout["method"]).lower() == "density": autopct = "%1.1f%%" else: - if (self.layout["method"].lower() in ["sum", "count"]) or ( - (self.layout["method"].lower() in ["min", "max"]) + if (str(self.layout["method"]).lower() in ["sum", "count"]) or ( + (str(self.layout["method"]).lower() in ["min", "max"]) and (self.layout["of_cat"] == "int") ): category = "int" diff --git a/verticapy/plotting/_matplotlib/spider.py b/verticapy/plotting/_matplotlib/spider.py index 845f1969c..a3351a618 100755 --- a/verticapy/plotting/_matplotlib/spider.py +++ b/verticapy/plotting/_matplotlib/spider.py @@ -90,7 +90,7 @@ def draw( ax.set_yticks(y_ticks) ax.set_rgrids(y_ticks, angle=180.0, fmt="%0.1f") ax.set_xlabel(self.layout["columns"][0]) - ax.set_ylabel(self.layout["method"]) + ax.set_ylabel(self.layout["method_of"]) if len(self.layout["columns"]) > 1: ax.legend( title=self.layout["columns"][1], diff --git a/verticapy/plotting/_plotly/bar.py b/verticapy/plotting/_plotly/bar.py index 2f87f887a..456afced2 100755 --- a/verticapy/plotting/_plotly/bar.py +++ b/verticapy/plotting/_plotly/bar.py @@ -43,7 +43,7 @@ def _compute_method(self) -> Literal["1D"]: def _init_style(self) -> None: self.init_trace_style = {"marker_color": self.get_colors(idx=0)} self.init_layout_style = { - "yaxis_title": self.layout["method"], + "yaxis_title": self.layout["method_of"], "xaxis_title": self.layout["column"], "width": 100 + 100 * len(self.layout["labels"]), "height": 500, @@ -90,7 +90,7 @@ def _compute_method(self) -> Literal["2D"]: # Styling Methods. def _init_style(self) -> None: self.init_layout_style = { - "yaxis_title": self.layout["method"], + "yaxis_title": self.layout["method_of"], "legend_title_text": self.layout["columns"][1], "xaxis_title": self.layout["columns"][0], "width": (150 + 40 * len(self.layout["x_labels"])) diff --git a/verticapy/plotting/_plotly/barh.py b/verticapy/plotting/_plotly/barh.py index 279d5f519..f77e6c2d9 100644 --- a/verticapy/plotting/_plotly/barh.py +++ b/verticapy/plotting/_plotly/barh.py @@ -44,7 +44,7 @@ def _compute_method(self) -> Literal["1D"]: def _init_style(self) -> None: self.init_trace_style = {"marker_color": self.get_colors(idx=0)} self.init_layout_style = { - "xaxis_title": self.layout["method"], + "xaxis_title": self.layout["method_of"], "yaxis_title": self.layout["column"], # "width": 500 , "height": 100 * len(self.layout["labels"]), @@ -89,7 +89,7 @@ def _compute_method(self) -> Literal["2D"]: def _init_style(self) -> None: self.init_layout_style = { - "xaxis_title": self.layout["method"], + "xaxis_title": self.layout["method_of"], "legend_title_text": self.layout["columns"][1], "yaxis_title": self.layout["columns"][0], "width": 500, diff --git a/verticapy/plotting/_plotly/pie.py b/verticapy/plotting/_plotly/pie.py index 105840dcd..559518da9 100644 --- a/verticapy/plotting/_plotly/pie.py +++ b/verticapy/plotting/_plotly/pie.py @@ -44,9 +44,10 @@ def _init_style(self) -> None: "hovertemplate": "%{label} ", } self.init_layout_style = { - "title_text": self.layout["column"], + "title_text": self.layout["method_of"], "title_x": 0.5, "title_xanchor": "center", + "legend": {"title": self.layout["column"]}, } # Draw diff --git a/verticapy/plotting/base.py b/verticapy/plotting/base.py index 06d3d1d0d..d48059b8a 100755 --- a/verticapy/plotting/base.py +++ b/verticapy/plotting/base.py @@ -29,6 +29,7 @@ from verticapy._typing import ( ArrayLike, NoneType, + PlottingMethod, PythonNumber, PythonScalar, SQLColumns, @@ -486,7 +487,9 @@ def sort_chart_2d( # Formatting Methods. @staticmethod - def _map_method(method: str, of: str) -> tuple[str, str, Optional[Callable], bool]: + def _map_method( + method: Optional[str], of: Optional[str] + ) -> tuple[Optional[str], Optional[str], Optional[Callable], bool]: is_standard = True fun_map = { "avg": np.mean, @@ -494,15 +497,23 @@ def _map_method(method: str, of: str) -> tuple[str, str, Optional[Callable], boo "max": max, "sum": sum, } - method = method.lower() + if isinstance(method, str): + method = method.lower() if method == "median": method = "50%" elif method == "mean": method = "avg" + no_agg = False + if isinstance(method, NoneType) and (of): + no_agg = True if ( - method not in ["avg", "min", "max", "sum", "density", "count"] - and "%" != method[-1] - ) and of: + isinstance(method, str) + and ( + method not in ["avg", "min", "max", "sum", "density", "count"] + and "%" != method[-1] + ) + and of + ): raise ValueError( "Parameter 'of' must be empty when using customized aggregations." ) @@ -528,17 +539,25 @@ def fun(x: ArrayLike) -> float: "The parameter 'method' must be in [avg|mean|min|max|sum|" f"median|q%] or a customized aggregation. Found {method}." ) - elif method in ["density", "count"]: + elif method in ["density", "count"] and not (no_agg): aggregate = "count(*)" fun = sum - elif isinstance(method, str): + elif isinstance(method, str) and not (no_agg): aggregate = method fun = None is_standard = False + elif isinstance(method, NoneType) and not (of): + method = "density" + aggregate = "count(*)" + fun = sum + elif no_agg: + method = None + aggregate = None + fun = None else: raise ValueError( "The parameter 'method' must be in [avg|mean|min|max|sum|" - f"median|q%] or a customized aggregation. Found {method}." + f"median|q%|None] or a customized aggregation. Found {method}." ) return method, aggregate, fun, is_standard @@ -604,7 +623,7 @@ def _compute_importance(self) -> tuple[np.ndarray, np.ndarray, np.ndarray]: def _compute_plot_params( self, vdc: "vDataColumn", - method: str = "density", + method: PlottingMethod = "density", of: Optional[str] = None, max_cardinality: int = 6, nbins: int = 0, @@ -641,13 +660,25 @@ def _compute_plot_params( is_numeric = vdc.isnum() and not vdc.isbool() is_date = vdc.isdate() is_bool = vdc.isbool() + no_agg = isinstance(method, NoneType) cast = "::int" if is_bool else "" is_categorical = False # case when categorical - if (((cardinality <= max_cardinality) or not is_numeric) or pie) and not ( - is_date - ): - if ((is_numeric) and not pie) or (is_bool): + if ( + (((cardinality <= max_cardinality) or not is_numeric) or pie) + and not (is_date) + ) or (no_agg): + if no_agg: + query = f""" + SELECT + {vdc}, + {of} + FROM {vdc._parent} + WHERE {vdc} IS NOT NULL + AND {of} IS NOT NULL + ORDER BY {vdc} ASC + LIMIT {max_cardinality}""" + elif ((is_numeric) and not pie) or (is_bool): query = f""" SELECT {vdc}, @@ -708,7 +739,7 @@ def _compute_plot_params( item[1] / float(count) if not isinstance(item[1], NoneType) else 0 for item in query_result ] - if (method.lower() == "density") + if (str(method).lower() == "density") else [ item[1] if not isinstance(item[1], NoneType) else 0 for item in query_result @@ -815,6 +846,12 @@ def _compute_plot_params( labels.reverse() metric, desc = self.get_category_desc(categoryorder) y, labels = self.sort_chart_1d(y, labels=labels, metric=metric, desc=desc) + if not (method): + method_of = self._clean_quotes(of) + elif of: + method_of = method + f"({self._clean_quotes(of)})" + else: + method_of = method self.data = { "x": x, "y": y, @@ -827,10 +864,10 @@ def _compute_plot_params( "labels": [li if not isinstance(li, NoneType) else "None" for li in labels], "column": self._clean_quotes(vdc._alias), "method": method, - "method_of": method + f"({of})" if of else method, + "method_of": method_of, "of": self._clean_quotes(of), "of_cat": vdc._parent[of].category() if of else None, - "aggregate": clean_query(aggregate), + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, "categoryorder": categoryorder, @@ -908,16 +945,22 @@ def _compute_hists_params( ) cols += [column] data[self._clean_quotes(column)] = copy.deepcopy(self.data) + if not (method): + method_of = self._clean_quotes(of) + elif of: + method_of = method + f"({self._clean_quotes(of)})" + else: + method_of = method self.data = data self.layout = { "columns": self._clean_quotes(cols), "categories": categories, "by": self._clean_quotes(by), "method": method, - "method_of": method + f"({of})" if of else method, + "method_of": method_of, "of": self._clean_quotes(of), "of_cat": vdf[of].category() if of else None, - "aggregate": clean_query(aggregate), + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, "has_category": bool(categories), @@ -1234,6 +1277,12 @@ def _compute_pivot_table( metric=metric, desc=desc, ) + if not (method): + method_of = self._clean_quotes(of) + elif of: + method_of = method + f"({self._clean_quotes(of)})" + else: + method_of = method self.data = { "X": X, } @@ -1244,10 +1293,10 @@ def _compute_pivot_table( "vmin": None, "columns": self._clean_quotes(columns), "method": method, - "method_of": method + f"({of})" if of else method, + "method_of": method_of, "of": self._clean_quotes(of), "of_cat": vdf[of].category() if of else None, - "aggregate": clean_query(aggregate), + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, "categoryorder": categoryorder, @@ -1420,15 +1469,28 @@ def _compute_aggregate( over = "/" + str(float(vdf.shape()[0])) else: over = "" - X = np.array( - _executeSQL( - query=f""" + if isinstance(method, NoneType) and of: + column = vdf.format_colnames(of) + query = f""" + SELECT + /*+LABEL('plotting._compute_aggregate')*/ + {", ".join(columns)}, + {column} + FROM {vdf}""" + method_of = f"max({self._clean_quotes(of)})" + aggregate_fun = max + else: + query = f""" SELECT /*+LABEL('plotting._compute_aggregate')*/ {", ".join(columns)}, {aggregate}{over} FROM {vdf} - GROUP BY {", ".join(columns)}""", + GROUP BY {", ".join(columns)}""" + method_of = method + f"({self._clean_quotes(of)})" if of else method + X = np.array( + _executeSQL( + query=query, title="Grouping all the elements for the Hexbin Plot", method="fetchall", ) @@ -1437,10 +1499,10 @@ def _compute_aggregate( self.layout = { "columns": self._clean_quotes(columns), "method": method, - "method_of": method + f"({of})" if of else method, + "method_of": method_of, "of": self._clean_quotes(of), "of_cat": vdf[of].category() if of else None, - "aggregate": clean_query(aggregate), + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, } @@ -1823,13 +1885,19 @@ def _compute_candle_aggregate( .sort(order_by) .to_numpy() ) + if not (method): + method_of = self._clean_quotes(of) + elif of: + method_of = method + f"({self._clean_quotes(of)})" + else: + method_of = method self.data = {"x": X[:, 0], "Y": X[:, 1:5], "z": X[:, 5], "q": q} self.layout = { "column": self._clean_quotes(column), "order_by": self._clean_quotes(order_by), "method": method, - "method_of": method + f"({column})" if of else method, - "aggregate": clean_query(aggregate), + "method_of": method_of, + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, } @@ -1959,14 +2027,20 @@ def _compute_rollup( ) vdf_tmp_i = vdf_tmp_i.sort(sort_values) groups += [vdf_tmp_i.to_numpy().T] + if not (method): + method_of = self._clean_quotes(of) + elif of: + method_of = method + f"({self._clean_quotes(of)})" + else: + method_of = method self.data = {"groups": np.array(groups, dtype=object)} self.layout = { "columns": self._clean_quotes(columns), "method": method, - "method_of": method + f"({of})" if of else method, + "method_of": method_of, "of": self._clean_quotes(of), "of_cat": vdf[of].category() if of else None, - "aggregate": clean_query(aggregate), + "aggregate": clean_query(aggregate) if aggregate else None, "aggregate_fun": aggregate_fun, "is_standard": is_standard, } diff --git a/verticapy/tests/sql/test_sql.py b/verticapy/tests/sql/test_sql.py index 0a5b6cd63..bac50af15 100755 --- a/verticapy/tests/sql/test_sql.py +++ b/verticapy/tests/sql/test_sql.py @@ -19,7 +19,7 @@ import pytest # Standard Python Modules -import warnings, os +import os # VerticaPy import verticapy diff --git a/verticapy/tests/utilities/test_utilities.py b/verticapy/tests/utilities/test_utilities.py index 862643796..a54c2dbaa 100755 --- a/verticapy/tests/utilities/test_utilities.py +++ b/verticapy/tests/utilities/test_utilities.py @@ -16,7 +16,7 @@ """ # Pytest -import pytest, warnings +import pytest # Other Modules import pandas as pd diff --git a/verticapy/tests_new/core/vdataframe/test_sys.py b/verticapy/tests_new/core/vdataframe/test_sys.py index 6a8ffe30f..bd6a677d5 100644 --- a/verticapy/tests_new/core/vdataframe/test_sys.py +++ b/verticapy/tests_new/core/vdataframe/test_sys.py @@ -197,6 +197,5 @@ def test_rename(self, titanic_vd_fun): """ test function - rename """ - titanic_vd_fun["sex"].rename("gender") - columns = titanic_vd_fun.get_columns() + columns = titanic_vd_fun["sex"].rename("gender", inplace=False).get_columns() assert '"gender"' in columns and '"sex"' not in columns diff --git a/verticapy/tests_new/mlops/test_model_tracking.py b/verticapy/tests_new/mlops/test_model_tracking.py index 0314c46c2..d25ee713e 100644 --- a/verticapy/tests_new/mlops/test_model_tracking.py +++ b/verticapy/tests_new/mlops/test_model_tracking.py @@ -20,7 +20,6 @@ # Standard Python Modules from abc import abstractmethod -import warnings # VerticaPy from verticapy import drop, set_option