reborn.viewers package

Subpackages

Submodules

reborn.viewers.pandaviews module

Modified by R.A. Kirian from original source: https://gist.github.com/jsexauer/f2bb0cc876828b54f2ed

Quick and Dirty Qt app to view pandas DataFrames. Includes sorting, filtering, and plotting.

Based on qtpandas in pandas sandbox module, by Jev Kuznetsov

class reborn.viewers.pandaviews.WidgetedCell(widget)[source]

Bases: object

Set as the value of an element in a pandas DataFrame to create a widget You may also want your widget to implement the getWidgetedCellState and setWidgetedCellState methods so that interactions with the controls persist.

Create a widget in the DataFrameWidget cell

Parameters:
  • widget (subclass of QWidget) – Widget to display in cell. The constructor of widget must accept only

  • argument (one)

  • inside. (the parent widget to build widget)

class reborn.viewers.pandaviews.DataFrameModel[source]

Bases: QAbstractTableModel

data model for a DataFrame class

RawDataRole = 64
RawIndexRole = 65
set_dataframe(dataframe)[source]

Set or change pandas DataFrame to show

property df
beginDynamicFilter()[source]

Effects of using the “filter” function will not become permanent until endDynamicFilter called

endDynamicFilter()[source]

Makes permanent the effects of the dynamic filter

cancelDynamicFilter()[source]

Cancel the dynamic filter

headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.ItemDataRole.DisplayRole) Any[source]
data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) Any[source]
flags(self, index: QModelIndex) Qt.ItemFlags[source]
rowCount(self, parent: QModelIndex = QModelIndex()) int[source]
columnCount(self, parent: QModelIndex = QModelIndex()) int[source]
sort(self, column: int, order: Qt.SortOrder = Qt.AscendingOrder)[source]
filter(col_ix, needle)[source]

Filter DataFrame view. Case Insenstive. Filters the DataFrame view to include only rows whos value in col contains the needle. Example: a needle of “Ab” will show rows with “absolute” and “REABSOLVE”.

Parameters:
  • col_ix (int) – Column index in df to filter

  • needle (str) – String to search df_view for

filterIsIn(col_ix, include)[source]
filterFunction(col_ix, function)[source]
reset()[source]
class reborn.viewers.pandaviews.DataFrameSortFilterProxyModel[source]

Bases: QSortFilterProxyModel

setSourceModel(self, sourceModel: Optional[QAbstractItemModel])[source]
sort(self, column: int, order: Qt.SortOrder = Qt.AscendingOrder)[source]
setFilterString(needle)[source]

Filter DataFrame using df[col].str.contains(needle). Case insensitive.

setFilterList(filter_list)[source]

Filter DataFrame using df[col].isin(filter_list).

setFilterFunction(func)[source]

Filter DataFrame using df[col].apply(func). Func should return True or False

property df
filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) bool[source]
filterAcceptsColumn(self, source_column: int, source_parent: QModelIndex) bool[source]
setFilterRegExp(self, regExp: QRegExp)[source]
setFilterRegExp(self, pattern: str) None
setFilterWildcard(self, pattern: str)[source]
setFilterFixedString(self, pattern: str)[source]
class reborn.viewers.pandaviews.DynamicFilterLineEdit(*args, **kwargs)[source]

Bases: QLineEdit

Filter textbox for a DataFrameTable

bind_dataframewidget(host, col_ix)[source]

Bind this DynamicFilterLineEdit to a DataFrameTable column :param host: Host to filter :type host: DataFrameWidget :param col_ix: Index of column of host to filter :type col_ix: int

property host
focusInEvent(self, a0: Optional[QFocusEvent])[source]
class reborn.viewers.pandaviews.DynamicFilterMenuAction(parent, menu, col_ix)[source]

Bases: QWidgetAction

Filter textbox in column-header right-click menu

Filter textbox in column right-click menu :param parent: Parent who owns the DataFrame to filter :type parent: DataFrameWidget :param menu: Menu object I am located on :type menu: QMenu :param col_ix: Index of column used in pandas DataFrame we are to filter :type col_ix: int

class reborn.viewers.pandaviews.FilterListMenuWidget(parent, menu, col_ix)[source]

Bases: QWidgetAction

Filter textbox in column-right click menu

Filter textbox in column right-click menu :param parent: Parent who owns the DataFrame to filter :type parent: DataFrameWidget :param menu: Menu object I am located on :type menu: QMenu :param col_ix: Column index used in pandas DataFrame we are to filter :type col_ix: int :param label: Label in popup menu :type label: str

on_list_itemChanged(item)[source]
class reborn.viewers.pandaviews.DataFrameItemDelegate[source]

Bases: QStyledItemDelegate

Implements WidgetedCell

createEditor(self, parent: Optional[QWidget], option: QStyleOptionViewItem, index: QModelIndex) Optional[QWidget][source]
setModelData(self, editor: Optional[QWidget], model: Optional[QAbstractItemModel], index: QModelIndex)[source]
paint(self, painter: Optional[QPainter], option: QStyleOptionViewItem, index: QModelIndex)[source]
class reborn.viewers.pandaviews.DataFrameWidget(parent=None, df=None)[source]

Bases: QTableView

DataFrameTable Create a widget to display a pandas DataFrame.

Parameters:
  • parent (QObject) – Parent object (likely window or canvas)

  • df (pandas DataFrame, optional) – DataFrame to display

dataFrameChanged

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

cellClicked

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

make_cell_context_menu(menu, row_ix, col_ix)[source]

Create the menu displayed when right-clicking on a cell. Overwrite this method to add custom right-click options

Parameters:
  • menu (QMenu) – Menu to which to add actions

  • row_ix (int) – Row location in dataframe

  • col_ix (int) – Column location in dataframe

Returns:

Same menu passed in, with added actions

Return type:

menu (QMenu)

contextMenuEvent(event)[source]

Implements right-clicking on cell.

NOTE: You probably want to overwrite make_cell_context_menu, not this function, when subclassing.

plot_single_column(col_ix)[source]
setDataFrame(df)[source]
filter(col_ix, needle)[source]
filterIsIn(col_ix, include)[source]
property df
keyPressEvent(event)[source]

Implements keyboard shortcuts

copy()[source]

Copy selected cells into copy-buffer

custom_filter(col_ix)[source]
class reborn.viewers.pandaviews.DataFrameApp(df, title='Inspecting DataFrame')[source]

Bases: QMainWindow

Sample DataFrameTable Application

datatable_updated()[source]
reborn.viewers.pandaviews.view_pandas_dataframe(df)[source]

Module contents