How to use pandasgui - 10 common examples

To help you get started, we’ve selected a few pandasgui 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 adamerose / pandasgui / pandasgui / widgets / plotly_viewer.py View on Github external
import os
import sys
import tempfile

from plotly.io import to_html
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt

from pandasgui.utility import get_logger

logger = get_logger(__name__)
# If QtWebEngineWidgets is imported while a QtWidgets.QApplication instance already exists it will fail, so we have to hack it
try:
    from PyQt5 import QtWebEngineWidgets
except ImportError as e:
    if (
        e.msg
        == "QtWebEngineWidgets must be imported before a QCoreApplication instance is created"
    ):
        logger.info("Killing QtWidgets.QApplication to reimport QtWebEngineWidgets")
        from PyQt5 import QtWidgets

        app = QtWidgets.QtWidgets.QApplication.instance()
        if app is not None:
            import sip

            app.quit()
github adamerose / pandasgui / pandasgui / widgets / dataframe_explorer.py View on Github external
"Min": df.min(numeric_only=True),
                "Max": df.max(numeric_only=True),
            }
        )
        w = DataFrameViewer(stats_df, editable=self.editable)
        w.setAutoFillBackground(True)
        return w


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

    from pandasgui.datasets import iris, flights, multi, pokemon

    # Create and show widget
    dfe = DataFrameExplorer(flights)
    dfe.show()

    sys.exit(app.exec_())
github adamerose / pandasgui / pandasgui / widgets / dialogs.py View on Github external
y = dict["Y Variable"][0]
            c = dict["Color By"][0]
        except IndexError:
            c = None

        sns.scatterplot(x, y, c, data=df)
        plt.show()


if __name__ == "__main__":
    import sys
    from PyQt5.QtWidgets import QApplication

    app = QApplication(sys.argv)

    test = Dragger(sources=["a", "b"], destinations=["x", "y", "z"])
    test.show()
    sys.exit(app.exec_())
github adamerose / pandasgui / pandasgui / widgets / dialogs.py View on Github external
def makePicker(self):
        self.layout.removeWidget(self.picker)
        self.df[self.column_name].astype(str).unique()
        self.picker = Dragger(
            self.names.text().split(","), self.df[self.column_name].astype(str).unique()
        )
        print(self.df[self.column_name].astype(str).unique())
        self.layout.addWidget(self.picker)
github adamerose / pandasgui / pandasgui / widgets / dialogs.py View on Github external
def __init__(self, df, column):
        super().__init__()

        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)
        self.df = df
        from pandasgui import show

        self.column_name = column
        self.names = QtWidgets.QLineEdit()
        self.names.textChanged.connect(self.makePicker)

        self.picker = Dragger(["col1", "col2", "col3"], df[column].astype(str).unique())

        # Add button
        btnFinish = QtWidgets.QPushButton("Finish")
        btnFinish.clicked.connect(self.finish)
        btnReset = QtWidgets.QPushButton("Reset")
        btnReset.clicked.connect(self.finish)
        buttonLayout = QtWidgets.QHBoxLayout()
        spacer = QtWidgets.QSpacerItem(
            0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum
        )
        buttonLayout.addSpacerItem(spacer)
        buttonLayout.addWidget(btnReset)
        buttonLayout.addWidget(btnFinish)

        # Add all to layout
        self.layout.addLayout(buttonLayout)
github adamerose / pandasgui / demo.py View on Github external
from pandasgui import show
import numpy as np
import pandas as pd

# Example 1 - Basic usage
df = pd.DataFrame(
    np.random.rand(5, 5),
    columns=["col1", "col2", "col3", "col4", "col5"],
    index=["A", "B", "C", "D", "E"],
)
show(df)

# Example 2 - Multiple DataFrames
from pandasgui.datasets import pokemon, titanic, mpg

show(pokemon, titanic, mileage=mpg)

# Example 3 - Multiple DataFrames with dictionary unpacking
from pandasgui.datasets import pokemon, titanic, mpg

df_dict = {"pokemon": pokemon, "titanic": titanic, "mileage": mpg}
show(**df_dict)
github adamerose / pandasgui / pandasgui / demo.py View on Github external
'Item': {0: 'Pencil', 1: 'Binder', 2: 'Pencil', 3: 'Pen', 4: 'Pencil', 5: 'Binder', 6: 'Pencil', 7: 'Pencil',
                 8: 'Pencil'}, 'Units': {0: 95, 1: 50, 2: 36, 3: 27, 4: 56, 5: 60, 6: 75, 7: 90, 8: 32},
        'UnitCost': {0: 1.99, 1: 19.99, 2: 4.99, 3: 19.99, 4: 2.99, 5: 4.99, 6: 1.99, 7: 4.99, 8: 1.99},
        'Total': {0: 189.05, 1: 999.5, 2: 179.64, 3: 539.73, 4: 167.44, 5: 299.4, 6: 149.25, 7: 449.1, 8: 63.68}}
    df1 = pd.DataFrame(sample_data)

    df2 = pd.read_csv('sample_data/pokemon.csv')

    tuples = [('A', 'one', 'x'), ('A', 'one', 'y'), ('A', 'two', 'x'), ('A', 'two', 'y'),
              ('B', 'one', 'x'), ('B', 'one', 'y'), ('B', 'two', 'x'), ('B', 'two', 'y')]
    index = pd.MultiIndex.from_tuples(tuples, names=['first', 'second', 'third'])
    df3 = pd.DataFrame(pd.np.random.randn(8, 8), index=index[:8], columns=index[:8])
    # df = df.reset_index()
    show(df1, nonblocking=True)
    show(df2)
    show(df3)
github adamerose / pandasgui / pandasgui / demo.py View on Github external
'Rep': {0: 'Jones', 1: 'Kivell', 2: 'Jardine', 3: 'Gill', 4: 'Sorvino', 5: 'Jones', 6: 'Andrews', 7: 'Jardine',
                8: 'Thompson'},
        'Item': {0: 'Pencil', 1: 'Binder', 2: 'Pencil', 3: 'Pen', 4: 'Pencil', 5: 'Binder', 6: 'Pencil', 7: 'Pencil',
                 8: 'Pencil'}, 'Units': {0: 95, 1: 50, 2: 36, 3: 27, 4: 56, 5: 60, 6: 75, 7: 90, 8: 32},
        'UnitCost': {0: 1.99, 1: 19.99, 2: 4.99, 3: 19.99, 4: 2.99, 5: 4.99, 6: 1.99, 7: 4.99, 8: 1.99},
        'Total': {0: 189.05, 1: 999.5, 2: 179.64, 3: 539.73, 4: 167.44, 5: 299.4, 6: 149.25, 7: 449.1, 8: 63.68}}
    df1 = pd.DataFrame(sample_data)

    df2 = pd.read_csv('sample_data/pokemon.csv')

    tuples = [('A', 'one', 'x'), ('A', 'one', 'y'), ('A', 'two', 'x'), ('A', 'two', 'y'),
              ('B', 'one', 'x'), ('B', 'one', 'y'), ('B', 'two', 'x'), ('B', 'two', 'y')]
    index = pd.MultiIndex.from_tuples(tuples, names=['first', 'second', 'third'])
    df3 = pd.DataFrame(pd.np.random.randn(8, 8), index=index[:8], columns=index[:8])
    # df = df.reset_index()
    show(df1, nonblocking=True)
    show(df2)
    show(df3)
github adamerose / pandasgui / demo.py View on Github external
np.random.rand(5, 5),
    columns=["col1", "col2", "col3", "col4", "col5"],
    index=["A", "B", "C", "D", "E"],
)
show(df)

# Example 2 - Multiple DataFrames
from pandasgui.datasets import pokemon, titanic, mpg

show(pokemon, titanic, mileage=mpg)

# Example 3 - Multiple DataFrames with dictionary unpacking
from pandasgui.datasets import pokemon, titanic, mpg

df_dict = {"pokemon": pokemon, "titanic": titanic, "mileage": mpg}
show(**df_dict)
github adamerose / pandasgui / pandasgui / nonblocking.py View on Github external
win = PandasGUI(block=True, **kwargs)

    app.exec_()


def show_nonblocking(**kwargs):
    thread = multiprocessing.Process(target=start_gui, kwargs=kwargs)
    thread.start()


if __name__ == '__main__':
    from pandasgui import show

    from pandasgui.datasets import iris, flights, multi, pokemon

    show(iris, flights, multi, pokemon)