How to use the autovizwidget.autovizwidget.widget.encoding.Encoding function in autovizwidget

To help you get started, we’ve selected a few autovizwidget examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter-incubator / sparkmagic / autovizwidget / autovizwidget / widget / encodingwidget.py View on Github external
description="X", value=self.encoding.x)
        self.x_view.on_trait_change(self._x_changed_callback, 'value')
        self.x_view.layout.width = "200px"

        # Y
        options_y_view = {text(i): text(i) for i in self.df.columns}
        options_y_view["-"] = None
        y_column_view = self.ipywidget_factory.get_dropdown(options=options_y_view,
                                                            description="Y", value=self.encoding.y)
        y_column_view.on_trait_change(self._y_changed_callback, 'value')
        y_column_view.layout.width = "200px"

        # Y aggregator
        value_for_view = self._get_value_for_aggregation(self.encoding.y_aggregation)
        self.y_agg_view = self.ipywidget_factory.get_dropdown(
            options={"-": Encoding.y_agg_none,
                     Encoding.y_agg_avg: Encoding.y_agg_avg,
                     Encoding.y_agg_min: Encoding.y_agg_min,
                     Encoding.y_agg_max: Encoding.y_agg_max,
                     Encoding.y_agg_sum: Encoding.y_agg_sum,
                     Encoding.y_agg_count: Encoding.y_agg_count},
            description="Func.",
            value=value_for_view)
        self.y_agg_view.on_trait_change(self._y_agg_changed_callback, 'value')
        self.y_agg_view.layout.width = "200px"

        # Y view
        self.y_view = self.ipywidget_factory.get_hbox()
        self.y_view.children = [y_column_view, self.y_agg_view]

        # Logarithmic X axis
        self.logarithmic_x_axis = self.ipywidget_factory.get_checkbox(
github jupyter-incubator / sparkmagic / autovizwidget / autovizwidget / widget / encodingwidget.py View on Github external
# Y
        options_y_view = {text(i): text(i) for i in self.df.columns}
        options_y_view["-"] = None
        y_column_view = self.ipywidget_factory.get_dropdown(options=options_y_view,
                                                            description="Y", value=self.encoding.y)
        y_column_view.on_trait_change(self._y_changed_callback, 'value')
        y_column_view.layout.width = "200px"

        # Y aggregator
        value_for_view = self._get_value_for_aggregation(self.encoding.y_aggregation)
        self.y_agg_view = self.ipywidget_factory.get_dropdown(
            options={"-": Encoding.y_agg_none,
                     Encoding.y_agg_avg: Encoding.y_agg_avg,
                     Encoding.y_agg_min: Encoding.y_agg_min,
                     Encoding.y_agg_max: Encoding.y_agg_max,
                     Encoding.y_agg_sum: Encoding.y_agg_sum,
                     Encoding.y_agg_count: Encoding.y_agg_count},
            description="Func.",
            value=value_for_view)
        self.y_agg_view.on_trait_change(self._y_agg_changed_callback, 'value')
        self.y_agg_view.layout.width = "200px"

        # Y view
        self.y_view = self.ipywidget_factory.get_hbox()
        self.y_view.children = [y_column_view, self.y_agg_view]

        # Logarithmic X axis
        self.logarithmic_x_axis = self.ipywidget_factory.get_checkbox(
            description="Log scale X", value=encoding.logarithmic_x_axis)
        self.logarithmic_x_axis.on_trait_change(self._logarithmic_x_callback, "value")

        # Logarithmic Y axis
github jupyter-incubator / sparkmagic / autovizwidget / autovizwidget / plotlygraphs / graphbase.py View on Github external
def _get_x_y_values_aggregated(df, x_column, y_column, y_aggregation):
        if y_aggregation == Encoding.y_agg_none:
            raise ValueError("No Y aggregation function specified.")

        # Pandas has some confusing behavior when it comes to aggregating
        # over empty dataframes. We're just going to explicitly block against that here.
        if len(df) == 0:
            raise InvalidEncodingError("Cannot display graph for an empty data set.")

        try:
            df_grouped = df.groupby(x_column)
        except TypeError:
            raise InvalidEncodingError("Cannot group by X column '{}' because of its type: '{}'."
                                       .format(df[x_column].dtype))
        else:
            try:
                if y_aggregation == Encoding.y_agg_avg:
                    df_transformed = df_grouped.mean()

autovizwidget

AutoVizWidget: An Auto-Visualization library for pandas dataframes

BSD-3-Clause
Latest version published 9 days ago

Package Health Score

82 / 100
Full package analysis