コード例 #1
0
    def __call__(self, kind="line", backend=None, **kwargs):

        positional_args = locals()
        plot_backend = KoalasPlotAccessor._get_plot_backend(backend)
        args = {**positional_args, **kwargs}
        # when using another backend, let the backend take the charge
        plot_data, kwds = self._format_args(plot_backend.__name__, self.data,
                                            kind, args)

        if plot_backend.__name__ != "databricks.koalas.plot":
            return plot_backend.plot(plot_data, kind=kind, **kwds)

        if kind not in KoalasPlotAccessor._koalas_all_kinds:
            raise ValueError("{} is not a valid plot kind".format(kind))

        from databricks.koalas import DataFrame, Series
        from databricks.koalas.plot.matplotlib import plot_series, plot_frame

        if isinstance(self.data, Series):
            if kind not in KoalasPlotAccessor._series_kinds:
                return unsupported_function(class_name="pd.Series",
                                            method_name=kind)()
            return plot_series(data=self.data, kind=kind, **kwds)
        elif isinstance(self.data, DataFrame):
            if kind not in KoalasPlotAccessor._dataframe_kinds:
                return unsupported_function(class_name="pd.DataFrame",
                                            method_name=kind)()
            return plot_frame(data=self.data, kind=kind, **kwds)
コード例 #2
0
ファイル: window.py プロジェクト: zuoxiaolei/koalas
def _unsupported_function_rolling(method_name, deprecated=False, reason=""):
    return unsupported_function(
        class_name="pandas.core.window.Rolling",
        method_name=method_name,
        deprecated=deprecated,
        reason=reason,
    )
コード例 #3
0
def _unsupported_function(method_name, deprecated=False, reason=""):
    return unsupported_function(
        class_name="pd.groupby.GroupBy",
        method_name=method_name,
        deprecated=deprecated,
        reason=reason,
    )
コード例 #4
0
    def box(self, **kwds):
        """
        Make a box plot of the Series columns.

        Parameters
        ----------
        **kwds : optional
            Additional keyword arguments are documented in
            :meth:`Koalas.Series.plot`.

        precision: scalar, default = 0.01
            This argument is used by Koalas to compute approximate statistics
            for building a boxplot. Use *smaller* values to get more precise
            statistics (matplotlib-only).

        Returns
        -------
        axes : :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray`
            Return an ndarray when ``subplots=True``.
            Return an custom object when ``backend!=matplotlib``.

        Notes
        -----
        There are behavior differences between Koalas and pandas.

        * Koalas computes approximate statistics - expect differences between
          pandas and Koalas boxplots, especially regarding 1st and 3rd quartiles.
        * The `whis` argument is only supported as a single number.
        * Koalas doesn't support the following argument(s).

          * `bootstrap` argument is not supported
          * `autorange` argument is not supported

        Examples
        --------
        Draw a box plot from a DataFrame with four columns of randomly
        generated data.

        For Series:

        .. plot::
            :context: close-figs

            >>> data = np.random.randn(25, 4)
            >>> df = ks.DataFrame(data, columns=list('ABCD'))
            >>> ax = df['A'].plot.box()

        This is an unsupported function for DataFrame type
        """
        from databricks.koalas import DataFrame, Series

        if isinstance(self.data, Series):
            return self(kind="box", **kwds)
        elif isinstance(self.data, DataFrame):
            return unsupported_function(class_name="pd.DataFrame",
                                        method_name="box")()
コード例 #5
0
ファイル: indexes.py プロジェクト: LSturtew/koalas
def _unsupported_function(method_name,
                          deprecated=False,
                          reason="",
                          cls="Index"):
    return unsupported_function(
        class_name="pd.{}".format(cls),
        method_name=method_name,
        deprecated=deprecated,
        reason=reason,
    )
コード例 #6
0
    def __call__(self, kind="line", backend=None, **kwargs):
        plot_backend = KoalasPlotAccessor._get_plot_backend(backend)
        plot_data = self.data

        if plot_backend.__name__ != "databricks.koalas.plot":
            data_preprocessor_map = {
                "pie": TopNPlot().get_top_n,
                "bar": TopNPlot().get_top_n,
                "barh": TopNPlot().get_top_n,
                "scatter": TopNPlot().get_top_n,
                "area": SampledPlot().get_sampled,
                "line": SampledPlot().get_sampled,
            }
            if not data_preprocessor_map[kind]:
                raise NotImplementedError(
                    "'%s' plot is not supported with '%s' plot "
                    "backend yet." % (kind, plot_backend.__name__))
            plot_data = data_preprocessor_map[kind](plot_data)
            return plot_backend.plot(plot_data, kind=kind, **kwargs)

        if kind not in KoalasPlotAccessor._koalas_all_kinds:
            raise ValueError("{} is not a valid plot kind".format(kind))

        from databricks.koalas import DataFrame, Series
        from databricks.koalas.plot.matplotlib import plot_series, plot_frame

        if isinstance(self.data, Series):
            if kind not in KoalasPlotAccessor._series_kinds:
                return unsupported_function(class_name="pd.Series",
                                            method_name=kind)()
            return plot_series(data=self.data, kind=kind, **kwargs)
        elif isinstance(self.data, DataFrame):
            if kind not in KoalasPlotAccessor._dataframe_kinds:
                return unsupported_function(class_name="pd.DataFrame",
                                            method_name=kind)()
            return plot_frame(data=self.data, kind=kind, **kwargs)
コード例 #7
0
ファイル: frame.py プロジェクト: igorlucci/koalas
def _unsupported_function(method_name, deprecated=False, reason=""):
    return unsupported_function(class_name="pd.DataFrame",
                                method_name=method_name,
                                deprecated=deprecated,
                                reason=reason)
コード例 #8
0
 def hexbin(self, **kwds):
     return unsupported_function(class_name="pd.DataFrame",
                                 method_name="hexbin")()