pandastable package

Submodules

pandastable.annotation module

pandastable.app module

pandastable.core module

Implements the core pandastable classes. Created Jan 2014 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.core.ChildToolBar(parent=None, parentapp=None)[source]

Bases: pandastable.core.ToolBar

Smaller toolbar for child table

class pandastable.core.Table(parent=None, model=None, dataframe=None, width=None, height=None, rows=20, cols=5, showtoolbar=False, showstatusbar=False, editable=True, enable_menus=True, **kwargs)[source]

Bases: tkinter.Canvas

A tkinter class for providing table functionality.

Parameters:
  • parent – parent Frame
  • model – a TableModel with some data
  • dataframe – a pandas DataFrame
  • width – width of frame
  • height – height of frame
  • rows – number of rows if creating empty table
  • cols – number of columns if creating empty table
  • showtoolbar – whether to show the toolbar, default False
  • showstatusbar – whether to show the statusbar
addColumn(newname=None)[source]

Add a new column

addRows(num=None)[source]

Add new rows

adjustColumnWidths(limit=30)[source]

Optimally adjust col widths to accomodate the longest entry in each column - usually only called on first redraw. :param limit: max number of columns to resize

aggregate()[source]

Show aggregate dialog

applyColumnFunction(evt=None)[source]

Apply column wise functions, applies a calculation per row and ceates a new column.

applyStringMethod()[source]

Apply string operation to column(s)

applyTransformFunction(evt=None)[source]

Apply resampling and transform functions on a single column.

autoAddColumns(numcols=None)[source]

Automatically add x number of cols

autoResizeColumns()[source]

Automatically set nice column widths and draw

checkDataEntry(event=None)[source]

do validation checks on data entry in a widget

cleanData()[source]

Deal with missing data

clearData(evt=None)[source]

Delete cells from gui event

clearFormatting()[source]
clearSelected()[source]

Clear selections

clearTable()[source]

Make an empty table

close(evt=None)[source]
closeChildTable()[source]

Close the child table

colorColumns(cols=None, color='gray')[source]

Color visible columns

colorRows()[source]

Color individual cells in column(s). Requires that the rowcolors dataframe has been set. This needs to be updated if the index is reset

contractColumns(factor=10)[source]

Reduce column widths

convertColumnNames(s='_')[source]

Convert col names so we can use numexpr

convertDates()[source]

Convert single or multiple columns into datetime

convertNumeric()[source]

Convert cols to numeric if possible

copy(rows, cols=None)[source]

Copy cell contents from clipboard - overwrites table.

copyColumn()[source]

Copy a column

copyIndex()[source]

Copy index to a column

copyTable(event=None)[source]

Copy from the clipboard

corrMatrix()[source]

Correlation matrix

createCategorical()[source]

Get a categorical column from selected

createChildTable(df, title=None, index=False, out=False)[source]

Add the child table

crosstab()[source]

Cross tabulation

deleteCells(rows, cols, answer=None)[source]

Clear the cell contents

deleteColumn(ask=True)[source]

Delete currently selected column(s)

deleteRow(ask=False)[source]

Delete a selected row

describe()[source]

Create table summary

doBindings()[source]

Bind keys and mouse clicks, this can be overriden

doCombine()[source]

Do combine/merge operation

doExport(filename=None)[source]

Do a simple export of the cell contents to csv

drawCellEntry(row, col, text=None)[source]

When the user single/double clicks on a text/number cell, bring up entry window and allow edits.

drawGrid(startrow, endrow)[source]

Draw the table grid lines

drawHighlighted()[source]

Color an arbitrary selection of cells. Set the ‘highlighted’ attribute which is a masked dataframe of the table.

drawMultipleCells()[source]

Draw an outline box for multiple cell selection

drawMultipleCols()[source]

Draw multiple column selections

drawMultipleRows(rowlist)[source]

Draw more than one row selection

drawRect(row, col, color=None, tag=None, delete=1)[source]

Cell is colored

drawRowHeader()[source]

User has clicked to select a cell

drawSelectedCol(col=None, delete=1, color=None, tag='colrect')[source]

Draw a highlight rect for the current column selection

drawSelectedRect(row, col, color=None, fillcolor=None)[source]

User has clicked to select a cell

drawSelectedRow()[source]

Draw a highlight rect for the currently selected rows

drawText(row, col, celltxt, align=None, single_line=True)[source]

Draw the text inside a cell area

duplicateRows()[source]

Make copy of rows

evalBar(evt=None)[source]

Use pd.eval to apply a function colwise or preset funcs.

evalFunction(evt=None)[source]

Apply a function to create new columns

expandColumns(factor=10)[source]

Reduce column widths

fillAcross(collist, rowlist)[source]

Fill across a row, or multiple rows

fillColumn()[source]

Fill a column with a data range

fillDown(rowlist, collist)[source]

Fill down a column, or multiple columns

findDuplicates()[source]

Find duplicate rows

findText(evt=None)[source]

Simple text search in whole table

flattenIndex()[source]

Flatten multiindex

functionsBar(evt=None)[source]

Apply python functions from a pre-defined set, this is for stuff that can’t be done with eval strings

getCanvasPos(row, col)[source]

Get the cell x-y coords as a fraction of canvas size

getCellCoords(row, col)[source]

Get x-y coordinates to drawing a cell in a given row/col

getColPosition(x)[source]

Get column position at coord

getFonts()[source]
getGeometry(frame)[source]

Get frame geometry

getPlotData()[source]

Plot data from selection

getRowPosition(y)[source]

Set row position

getRowsFromIndex(idx=None)[source]

Get row positions from index values

getRowsFromMask(mask)[source]
getScale()[source]
getSelectedColumn()[source]

Get currently selected column

getSelectedDataFrame()[source]

Return a sub-dataframe of the selected cells. Will try to convert object types to float so that plotting works.

getSelectedRow()[source]

Get currently selected row

getSelectedRowData()[source]

Return a sub-dataframe of the selected rows

getSelectionValues()[source]

Get values for current multiple cell selection

getVisibleCols(x1, x2)[source]

Get the visible column range

getVisibleRegion()[source]

Get visible region of canvas

getVisibleRows(y1, y2)[source]

Get the visible row range

get_col_clicked(event)[source]

Get column where event on the canvas occurs

get_memory()[source]

memory usage of current table

get_row_clicked(event)[source]

Get row where event on canvas occurs

gotonextCell()[source]

Move highlighted cell to next cell in row or a new col

gotonextRow()[source]

Programmatically set next row - eg. for button events

gotoprevRow()[source]

Programmatically set previous row - eg. for button events

groupby(colindex)[source]

Group by

handleCellEntry(row, col)[source]

Callback for cell entry

handleEntryMenu(*args)[source]

Callback for option menu in categorical columns entry

handle_arrow_keys(event)[source]

Handle arrow keys press

handle_double_click(event)[source]

Do double click stuff. Selected row/cols will already have been set with single click binding

handle_left_click(event)[source]

Respond to a single press

handle_left_ctrl_click(event)[source]

Handle ctrl clicks for multiple row selections

handle_left_release(event)[source]

Handle left mouse button release event

handle_left_shift_click(event)[source]

Handle shift click, for selecting multiple rows

handle_mouse_drag(event)[source]

Handle mouse moved with button held down, multiple selections

handle_right_click(event)[source]

respond to a right click

hidePlot()[source]

Hide plot frame

hideRowHeader()[source]

Hide the row header, must have run show() first

importCSV(filename=None, dialog=False, **kwargs)[source]

Import from csv file

importHDF(filename=None, dialog=False, **kwargs)[source]
insertRow()[source]

Insert a new row

isInsideTable(x, y)[source]

Returns true if x-y coord is inside table bounds

load(filename=None)[source]

load from a file

loadExcel(filename=None)[source]

Load excel file

loadPrefs(prefs=None)[source]

Load preferences from defaults

melt()[source]

Melt table

merge(table)[source]

Merge with another table.

mouse_wheel(event)[source]

Handle mouse wheel scroll for windows

moveColumns(names=None, pos='start')[source]

Move column(s) to start/end, used for large tables

movetoSelection(row=None, col=0, idx=None, offset=0)[source]

Move to a specific row/col, updating table

new()[source]

Clears all the data and makes a new table

paste(event=None)[source]

Paste a new table from the clipboard

pivot()[source]

Pivot table

placeColumn(col1, col2)[source]

Move col1 next to col2, useful for placing a new column made from the first one next to it so user can see it easily

plot3D()[source]
plotSelected()[source]

Plot the selected data in the associated plotviewer

popupMenu(event, rows=None, cols=None, outside=None)[source]

Add left and right click behaviour for canvas, should not have to override this function, it will take its values from defined dicts in constructor

query(evt=None)[source]

Do query

queryBar(evt=None)[source]

Query/filtering dialog

recalculateFunctions(omit=None)[source]

Re evaluate any columns that were derived from functions and dependent on other columns (except self derived?)

redraw(event=None, callback=None)[source]

Redraw table

redrawCell(row=None, col=None, recname=None, colname=None)[source]

Redraw a specific cell only

redrawVisible(event=None, callback=None)[source]

Redraw the visible portion of the canvas. This is the core redraw method. Refreshes all table elements. Called by redraw() method as shorthand.

Parameters:
  • event – tkinter event to trigger method, default None
  • callback – function to be called after redraw, default None
remove()[source]

Close table frame

renameIndex()[source]

Rename the row index

resample()[source]

Table time series resampling dialog. Should set a datetime index first.

resetColors()[source]
resetIndex(ask=True, drop=False)[source]

Reset index and redraw row header

resizeColumn(col, width)[source]

Resize a column by dragging

resized(event)[source]

Check if size changed when event triggered to avoid unnecessary redraws

save()[source]

Save current file

saveAs(filename=None)[source]

Save dataframe to file

selectAll(evt=None)[source]

Select all rows and cells

selectNone()[source]

Deselect current, called when table is redrawn with completely new cols and rows e.g. after model is updated.

setAlignment(colnames=None)[source]

Set column alignments, overrides global value

setColPositions()[source]

Determine current column grid positions

setColorByMask(col, mask, clr)[source]

Color individual cells in a column using a mask.

setColorbyValue()[source]

Set row colors in a column by values

setColumnColors(cols=None, clr=None)[source]

Set a column color and store it

setColumnType()[source]

Change the column dtype

setFont()[source]

Set font tuple

setPrecision(x, p)[source]

Set precision of a float value

setRowColors(rows=None, clr=None, cols=None)[source]

Set rows color from menu. :param rows: row numbers to be colored :param clr: color in hex :param cols: column numbers, can also use ‘all’

setRowHeight(h)[source]

Set the row height

setSelectedCells(startrow, endrow, startcol, endcol)[source]

Set a block of cells selected

setSelectedCol(col)[source]

Set currently selected column

setSelectedRow(row=None)[source]

Set currently selected row and reset multiple row list

setSelectedRows(rows)[source]
setTheme(name='light')[source]

Set theme

setWrap()[source]

Toogle column header wrap

set_defaults()[source]

Set default settings

set_rowcolors_index()[source]
set_xviews(*args)[source]

Set the xview of table and col header

set_yviews(*args)[source]

Set the xview of table and row header

setcellbackgr()[source]
setgrid_color()[source]
setindex()[source]

Set indexes

setrowselectedcolor()[source]

Set selected row color

show(callback=None)[source]

Adds column header and scrollbars and combines them with the current table adding all to the master frame provided in constructor. Table is then redrawn.

showAll()[source]

Re-show unfiltered

showIndex()[source]

Show the row index

showInfo()[source]

Show dataframe info

showPlot()[source]
showPlotViewer(parent=None)[source]

Create plot frame

showPreferences()[source]

Preferences dialog

showRowHeader()[source]

Show the row header if hidden, must have run show() first

show_progress_window(message=None)[source]

Show progress bar window for loading of data

showasText()[source]

Get table as formatted text - for printing

sortColumnIndex()[source]

Sort the column header by the current rows values

sortTable(columnIndex=None, ascending=1, index=False)[source]

Sort rows based on currently selected columns

statsViewer()[source]

Show model fitting dialog

storeCurrent()[source]

Store current version of the table before a major change is made

tableChanged()[source]

Callback to be used when dataframe changes so that other widgets and data can be updated

tableFromSelection()[source]

Create a new table from the selected cells

transform()[source]

Apply element-wise transform

transpose()[source]

Transpose table

undo(event=None)[source]

Undo last major table change

updateFunctions()[source]

Remove functions if a column has been deleted

updateModel(model=None)[source]

Should call this method when a new table model is loaded. Recreates widgets and redraws the table.

updateWidgets()[source]

Update some dialogs when table changed

update_rowcolors()[source]

Update row colors if present so that it syncs with current dataframe.

valueCounts()[source]

Value counts for column(s)

values_to_colors(x, cmap='jet', alpha=1)[source]

Convert columnn values to colors

zoomIn()[source]

Zoom in, increases font and row heights.

zoomOut()[source]

Zoom out, decreases font and row heights.

class pandastable.core.ToolBar(parent=None, parentapp=None)[source]

Bases: tkinter.ttk.Frame

Uses the parent instance to provide the functions

class pandastable.core.statusBar(parent=None, parentapp=None)[source]

Bases: tkinter.ttk.Frame

Status bar class

update()[source]

Update status bar

pandastable.data module

Module implementing the Data class that manages data for it’s associated PandasTable.

Created Jan 2014 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.data.TableModel(dataframe=None, rows=20, columns=5)[source]

Bases: object

A data model for the Table class that uses pandas

Parameters:
  • dataframe – pandas dataframe
  • rows – number of rows if empty table
  • columns – number of columns if empty table
addColumn(colname=None, dtype=None, data=None)[source]

Add a column

autoAddRows(num)[source]

Add n rows to end of dataframe. Will create rows with index starting from highest previous row count

copyIndex()[source]

Copy index to a column

deleteCells(rows, cols)[source]
deleteColumn(colindex)[source]

delete a column

deleteColumns(cols=None)[source]

Remove all cols or list provided

deleteRow(row, unique=True)[source]

Delete a row

deleteRows(rowlist=None, unique=True)[source]

Delete multiple or all rows

filterby()[source]
getColumnCount()[source]

Returns the number of columns in the data model

getColumnName(columnIndex)[source]

Returns the name of the given column by columnIndex

getColumnType(columnIndex)[source]

Get the column type

classmethod getIrisData()[source]

Get iris dataset

getRecordAtRow(rowindex)[source]

Get the entire record at the specifed row

getRowCount()[source]

Returns the number of rows in the table model.

classmethod getSampleData(rows=400, cols=5, n=2)[source]

Generate sample data :param rows: no. of rows :param cols: columns :param n: length of column names

classmethod getStackedData()[source]

Get a dataframe to pivot test

getValueAt(row, col)[source]

Returns the cell value at location specified by columnIndex and rowIndex.

getlongestEntry(colindex, n=500)[source]

Get the longest string in the column for determining width. Just uses the first n rows for speed

groupby(cols)[source]

Group by cols

initialiseFields()[source]

Create meta data fields

insertRow(row)[source]

Inserts a row at the required index by append/concat

keywords = {'colors': 'colors'}
load(filename, filetype=None)[source]

Load file, if no filetype given assume it’s pickle format

moveColumn(oldindex, newindex)[source]

Changes the order of columns

query()[source]
resetIndex(drop=False)[source]

Reset index behaviour

save(filename)[source]

Save dataframe

setValueAt(value, row, col, df=None)[source]

Change dataframe according to row/col numbers. You can also pass an arbitrary dataframe here.

setindex(colindex)[source]

Index setting behaviour

setup(dataframe, rows=20, columns=5)[source]

Create table model

transpose()[source]

Transpose dataframe

pandastable.dialogs module

Dialog classes. Created Oct 2014 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.dialogs.AggregateDialog(parent=None, df=None)[source]

Bases: pandastable.dialogs.BaseDialog

Provides a frame for split-apply-combine operations

apply()[source]

Apply operation

copyResult()[source]
createWidgets(m)[source]

Create a set of grp-agg-func options together

help()[source]

Help button code

quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

class pandastable.dialogs.AutoScrollbar(master=None, **kw)[source]

Bases: tkinter.ttk.Scrollbar

A scrollbar that hides itself if it’s not needed. only works if you use the grid geometry manager.

pack(**kw)[source]
place(**kw)[source]
set(lo, hi)[source]

Set the fractional values of the slider position (upper and lower ends as value between 0 and 1).

class pandastable.dialogs.BaseDialog(parent=None, df=None, title='')[source]

Bases: tkinter.ttk.Frame

Generic dialog - inherit from this and customise the createWidgets and apply methods.

apply()[source]

Code to run when Apply is pressed

buttonsFrame()[source]
createWidgets(m)[source]

Override this

help()[source]

Help button code

quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

class pandastable.dialogs.BaseTable(parent=None, width=280, height=190, rows=2, cols=2, **kwargs)[source]

Bases: tkinter.Canvas

Basic table class based on tk canvas. inherit from this to add your own functionality

doBindings()[source]
drawGrid()[source]
drawMultipleCells(rows, cols)[source]

Draw more than one row selection

drawSelectedRect(row, col, color='#c2c2d6', pad=4, tags='')[source]

User has clicked to select area

getCellCoords(row, col)[source]

Get x-y coordinates to drawing a cell in a given row/col

get_col_clicked(event)[source]

Get column where event on the canvas occurs

get_row_clicked(event)[source]

Get row where event on canvas occurs

handle_left_click(event)[source]

Respond to a single press

handle_mouse_drag(event)[source]

Handle mouse moved with button held down, multiple selections

redraw()[source]
update()[source]

Enter event loop until all pending events have been processed by Tcl.

class pandastable.dialogs.CombineDialog(parent=None, df1=None, df2=None)[source]

Bases: tkinter.ttk.Frame

Provides a frame for setting up merge/combine operations

apply()[source]

Apply operation

getResult(df)[source]

Show result of merge and let user choose to replace current table

help()[source]
quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

replaceTable()[source]

replace parent table

class pandastable.dialogs.CrosstabDialog(parent=None, df=None, title='')[source]

Bases: pandastable.dialogs.BaseDialog

apply()[source]

Apply crosstab

createWidgets(m)[source]

Create a set of grp-agg-func options together

help()[source]

Help button code

class pandastable.dialogs.EasyListbox(parent, width, height, yscrollcommand, listItemSelected)[source]

Bases: tkinter.Listbox

Customised list box to replace useless default one

clear()[source]

Deletes all items from the list box.

getIndex(item)[source]

Returns the index of item if it’s in the list box.

getSelectedIndex()[source]

Returns the index of the selected item or -1 if no item is selected.

getSelectedItem()[source]

Returns the selected item or the empty string if no item is selected.

setSelectedIndex(index)[source]

Selects the item at the index if it’s in the range.

triggerListItemSelected(event)[source]

Strategy method to respond to an item selection in the list box. Runs the client’s listItemSelected method with the selected index.

class pandastable.dialogs.FilterBar(parent, parentframe, cols)[source]

Bases: tkinter.ttk.Frame

Class providing filter widgets

booleanops = ['AND', 'OR', 'NOT']
close()[source]

Destroy and remove from parent

getFilter()[source]

Get filter values for this instance

operators = ['contains', 'excludes', 'equals', 'not equals', '>', '<', 'is empty', 'not empty', 'starts with', 'ends with', 'has length', 'is number', 'is lowercase', 'is uppercase']
update(cols)[source]

Enter event loop until all pending events have been processed by Tcl.

class pandastable.dialogs.FindReplaceDialog(table)[source]

Bases: tkinter.ttk.Frame

Find/replace dialog.

clear()[source]
close()[source]
find()[source]

Do string search. Creates a masked dataframe for results and then stores each cell coordinate in a list.

findAll()[source]

Highlight all found cells

findNext()[source]

Show next cell of search results

replace()[source]

Replace all instances of search text

setup()[source]
updated(name='', index='', mode='')[source]

Widgets changed so run search again

class pandastable.dialogs.ImportDialog(parent=None, filename=None)[source]

Bases: tkinter.ttk.Frame

Provides a frame for figure canvas and MPL settings

doImport()[source]

Do the import

quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

showText(encoding='utf-8')[source]

Show text contents

update()[source]

Reload previews

class pandastable.dialogs.MultipleValDialog(parent, title=None, initialvalues=None, labels=None, types=None, tooltips=None, width=14, **kwargs)[source]

Bases: tkinter.simpledialog.Dialog

Simple dialog to get multiple values

apply()[source]

process the data

This method is called automatically to process the data, after the dialog is destroyed. By default, it does nothing.

body(master)[source]

create dialog body.

return widget that should have initial focus. This method should be overridden, and is called by the __init__ method.

getResults(null=None)[source]

Return a dict of options/values

class pandastable.dialogs.Progress(parent, side='left')[source]

Bases: object

threaded progress bar for tkinter gui

pb_clear()[source]

stops the progress bar

pb_complete()[source]

stops the progress bar and fills it

pb_start()[source]

starts the progress bar

pb_stop()[source]

stops the progress bar

class pandastable.dialogs.ProgressDialog[source]

Bases: tkinter.Toplevel

class pandastable.dialogs.QueryDialog(table)[source]

Bases: tkinter.ttk.Frame

Use string query to filter. Will not work with spaces in column names, so these would need to be converted first.

addFilter()[source]

Add a filter using widgets

applyFilter(df, mask=None)[source]

Apply the widget based filters, returns a boolean mask

close()[source]
colorResult()[source]

Color filtered rows in main table

query(evt=None)[source]

Do query

setup()[source]
update()[source]

Enter event loop until all pending events have been processed by Tcl.

class pandastable.dialogs.SimpleEditor(parent=None, width=100, height=40, font=None)[source]

Bases: tkinter.ttk.Frame

Simple text editor

onClear()[source]

Clear text

onFind()[source]
onSave()[source]

Save text

class pandastable.dialogs.ToolTip(widget)[source]

Bases: object

Tooltip class for tkinter widgets

classmethod createToolTip(widget, text)[source]

Create a tooltip for a widget

hidetip(event=None)[source]

Hide tooltip

showtip(text, event=None)[source]

Display text in tooltip window

class pandastable.dialogs.VerticalScrolledFrame(parent, height=None, width=None, *args, **kw)[source]

Bases: tkinter.ttk.Frame

A pure Tkinter scrollable frame see http://tkinter.unpythonic.net/wiki/VerticalScrolledFrame. Use the ‘interior’ attribute to place widgets inside the scrollable frame.

pandastable.dialogs.addButton(frame, name, callback, img=None, tooltip=None, side='top', compound=None, width=None, padding=1)[source]

Add a button with image, toolip to a tkinter frame

pandastable.dialogs.addListBox(parent, values=[], width=10, height=6, label='')[source]

Add an EasyListBox

pandastable.dialogs.applyStyle(w)[source]

Apply style to individual widget to prevent widget color issues on linux

pandastable.dialogs.dialogFromOptions(parent, opts, groups=None, callback=None, sticky='news', layout='horizontal')[source]

Auto create tk vars and widgets for corresponding options and and return the enclosing frame

pandastable.dialogs.getBestGeometry(win, width=None)[source]

Calculate optimal geometry from screen size or given width

pandastable.dialogs.getDictfromTkVars(opts, tkvars, widgets)[source]
pandastable.dialogs.getListBoxSelection(w)[source]
pandastable.dialogs.getParentGeometry(parent)[source]
pandastable.dialogs.pickColor(parent, oldcolor)[source]
pandastable.dialogs.setGeometry(win, width=None)[source]

Set window geometry to center of screen

pandastable.dialogs.setWidgetStyles(widgets)[source]

set styles of list of widgets

pandastable.handlers module

Module for plot viewer event classes.

Created Jan 2016 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.handlers.DragHandler(parent, figure=None)[source]

Bases: object

A simple class to handle picking and dragging

button_press_event(event)[source]
connect()[source]

Connect events

disconnect()[source]

disconnect all the stored connection ids

drawSelectionRect()[source]

Draw a selection box

key_press_event(event)[source]

Handle key press

on_pick_event(event)[source]

Store which text object was picked and were the pick event occurs.

on_release_event(event)[source]

Update and store text/annotation position

pandastable.headers module

Implements the pandastable headers classes. Created Jan 2014 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.headers.ColumnHeader(parent=None, table=None, bg='gray25')[source]

Bases: tkinter.Canvas

Class that takes it’s size and rendering from a parent table and column names from the table model.

drawRect(col, tag=None, color=None, outline=None, delete=1)[source]

User has clicked to select a col

draw_resize_symbol(col)[source]

Draw a symbol to show that col can be resized when mouse here

handle_double_click(event)[source]

Double click sorts by this column.

handle_left_click(event)[source]

Does cell selection when left mouse button is clicked

handle_left_ctrl_click(event)[source]

Handle ctrl clicks - for multiple column selections

handle_left_release(event)[source]

When mouse released implement resize or col move

handle_left_shift_click(event)[source]

Handle shift click, for selecting multiple cols

handle_mouse_drag(event)[source]

Handle column drag, will be either to move cols or resize

handle_mouse_move(event)[source]

Handle mouse moved in header, if near divider draw resize symbol

handle_right_click(event)[source]

respond to a right click

handle_right_release(event)[source]
leave(event)[source]

Mouse left canvas event

popupMenu(event)[source]

Add left and right click behaviour for column header

redraw(align='w')[source]

Redraw column header

renameColumn()[source]

Rename column

setDefaults()[source]
within(val, l, d)[source]

Utility funtion to see if val is within d of any items in the list l

class pandastable.headers.IndexHeader(parent=None, table=None, width=40, height=25, bg='gray50')[source]

Bases: tkinter.Canvas

Class that displays the row index headings.

handle_left_click(event)[source]

Handle mouse left mouse click

redraw(align='w')[source]

Redraw row index header

class pandastable.headers.RowHeader(parent=None, table=None, width=50, bg='gray75')[source]

Bases: tkinter.Canvas

Class that displays the row headings (or DataFrame index). Takes it’s size and rendering from the parent table. This also handles row/record selection as opposed to cell selection

clearSelected()[source]

Clear selected rows

drawRect(row=None, tag=None, color=None, outline=None, delete=1)[source]

Draw a rect representing row selection

drawSelectedRows(rows=None)[source]

Draw selected rows, accepts a list or integer

handle_left_click(event)[source]

Handle left click

handle_left_ctrl_click(event)[source]

Handle ctrl clicks - for multiple row selections

handle_left_release(event)[source]
handle_left_shift_click(event)[source]

Handle shift click

handle_mouse_drag(event)[source]

Handle mouse moved with button held down, multiple selections

handle_right_click(event)[source]

respond to a right click

popupMenu(event, rows=None, cols=None, outside=None)[source]

Add left and right click behaviour for canvas, should not have to override this function, it will take its values from defined dicts in constructor

redraw(align='w', showkeys=False)[source]

Redraw row header

setWidth(w)[source]

Set width

toggleIndex()[source]

Toggle index display

pandastable.headers.createSubMenu(parent, label, commands)[source]

pandastable.images module

Images stored as PhotoImage objects, for buttons and logos. Created Oct 2008 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

pandastable.images.accept()[source]
pandastable.images.add()[source]
pandastable.images.add_col()[source]
pandastable.images.add_row()[source]
pandastable.images.aggregate()[source]
pandastable.images.calculate()[source]
pandastable.images.color_swatch()[source]
pandastable.images.contract_col()[source]
pandastable.images.copy()[source]
pandastable.images.cross()[source]
pandastable.images.del_col()[source]
pandastable.images.del_row()[source]
pandastable.images.delete()[source]
pandastable.images.end()[source]
pandastable.images.excel()[source]
pandastable.images.expand_col()[source]
pandastable.images.filtering()[source]
pandastable.images.fit()[source]
pandastable.images.font()[source]
pandastable.images.function()[source]
pandastable.images.importcsv()[source]
pandastable.images.melt()[source]
pandastable.images.merge()[source]
pandastable.images.new_proj()[source]
pandastable.images.next()[source]
pandastable.images.open_proj()[source]
pandastable.images.paste()[source]
pandastable.images.pivot()[source]
pandastable.images.plot()[source]
pandastable.images.plot_clear()[source]
pandastable.images.plot_prefs()[source]
pandastable.images.prefs()[source]
pandastable.images.prev()[source]
pandastable.images.refresh()[source]
pandastable.images.save()[source]
pandastable.images.save_proj()[source]
pandastable.images.search()[source]
pandastable.images.start()[source]
pandastable.images.table_delete()[source]
pandastable.images.table_multiple()[source]
pandastable.images.tilehorizontal()[source]
pandastable.images.tilevertical()[source]
pandastable.images.transpose()[source]
pandastable.images.zoom_in()[source]
pandastable.images.zoom_out()[source]

pandastable.plotting module

Module for pandastable plotting classes .

Created Jan 2014 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.plotting.AnimateOptions(parent=None)[source]

Bases: pandastable.plotting.TkOptions

Class for live update/animation of plots.

addWidgets()[source]

Custom dialogs for manually adding annotation items like text

getWriter()[source]
showDialog(parent, layout='horizontal')[source]

Create dialog widgets

start()[source]

start animation using a thread

stop()[source]

Stop animation loop

stream()[source]

Stream data into table and plot - not implemented yet

update()[source]

do live updating

updateCurrent(writer=None)[source]

Iterate over current table and update plot

class pandastable.plotting.AnnotationOptions(parent=None)[source]

Bases: pandastable.plotting.TkOptions

This class also provides custom tools for adding items to the plot

addArrow(kwds=None, key=None)[source]

Add line/arrow

addObject()[source]

Add an annotation object

addTextBox(kwds=None, key=None)[source]

Add a text annotation and store it using key

addWidgets()[source]

Custom dialogs for manually adding annotation items like text

clear()[source]

Clear annotations

redraw()[source]

Redraw all stored annotations in the right places after a plot update

showDialog(parent, layout='horizontal')[source]

Override because we need to add custom widgets

class pandastable.plotting.ExtraOptions(parent=None)[source]

Bases: pandastable.plotting.TkOptions

Class for additional formatting options like styles

addWidgets()[source]

Custom dialogs for manually adding annotation items like text

apply()[source]
reset()[source]
showDialog(parent, layout='horizontal')[source]

Create dialog widgets

class pandastable.plotting.MPL3DOptions(parent=None)[source]

Bases: pandastable.plotting.MPLBaseOptions

Class to provide 3D matplotlib options

applyOptions()[source]

Set the plot kwd arguments from the tk variables

defaultfont = 'monospace'
kinds = ['scatter', 'bar', 'contour', 'wireframe', 'surface']
class pandastable.plotting.MPLBaseOptions(parent=None)[source]

Bases: pandastable.plotting.TkOptions

Class to provide a dialog for matplotlib options and returning the selected prefs

applyOptions()[source]

Set the plot kwd arguments from the tk variables

defaultfont = 'monospace'
kinds = ['line', 'scatter', 'bar', 'barh', 'pie', 'histogram', 'boxplot', 'violinplot', 'dotplot', 'heatmap', 'area', 'hexbin', 'contour', 'imshow', 'scatter_matrix', 'density', 'radviz', 'venn']
legendlocs = ['best', 'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center']
update(df)[source]

Update data widget(s) when dataframe changes

class pandastable.plotting.PlotLayoutGrid(parent=None, width=280, height=205, rows=2, cols=2, **kwargs)[source]

Bases: pandastable.dialogs.BaseTable

handle_left_click(event)[source]

Respond to a single press

class pandastable.plotting.PlotLayoutOptions(parent=None)[source]

Bases: pandastable.plotting.TkOptions

resetGrid(event=None)[source]

update grid and redraw

setmultiviews(event=None)[source]
showDialog(parent, layout='horizontal')[source]

Override because we need to add custom bits

updateAxesList()[source]

Update axes list

updateFromGrid()[source]
class pandastable.plotting.PlotViewer(table, parent=None, showoptions=True)[source]

Bases: tkinter.ttk.Frame

Provides a frame for figure canvas and MPL settings.

Parameters:
  • table – parent table, required
  • parent – parent tkinter frame
  • layout – ‘horizontal’ or ‘vertical’
addWidgets()[source]

Add option widgets to control panel

applyPlotoptions()[source]

Apply the current plotter/options

autoscale(axis='y')[source]

Set all subplots to limits of largest range

bar3D(data, ax, kwds)[source]

3D bar plot

checkColumnNames(cols)[source]

Check length of column names

clear()[source]

Clear plot

close()[source]

Close the window

contourData(data)[source]

Get data for contour plot

dotplot(df, ax, kwds)[source]

Dot plot

getView()[source]
getcmap(name)[source]
heatmap(df, ax, kwds)[source]

Plot heatmap

meshData(x, y, z)[source]

Prepare 1D data for plotting in the form (x,y)->Z

plot2D(redraw=True)[source]

Plot method for current data. Relies on pandas plot functionality if possible. There is some temporary code here to make sure only the valid plot options are passed for each plot kind.

plot3D(redraw=True)[source]

3D plot

plotCurrent(redraw=True)[source]

Plot the current data

plotMultiViews(plot_types=['bar', 'scatter'])[source]

Plot multiple views of the same data in a grid

plotSplitData()[source]

Splits selected data up into multiple plots in a grid

removeSubplot()[source]

Remove a specific axis from the grid layout

replot(data=None)[source]

Re-plot using current parent table selection. Args: data: set current dataframe, otherwise use current table selection

savePlot(filename=None)[source]

Save the current plot

scatter(df, ax, alpha=0.8, marker='o', color=None, **kwds)[source]

A custom scatter plot rather than the pandas one. By default this plots the first column selected versus the others

scatter3D(data, ax, kwds)[source]

3D scatter plot

setAxisLabels(ax, kwds)[source]

Set a plots axis labels

setFigureOptions(axs, kwds)[source]

Set axis wide options such as ylabels, title

setGlobalOption(name='', *args)[source]

Set global value from widgets

setOption(option, value)[source]
setSubplotTitle()[source]

Set a subplot title if using grid layout

setupGUI()[source]

Add GUI elements

showWarning(text='plot error', ax=None)[source]

Show warning message in the plot window

toggle_options()[source]

Show/hide plot options

updateData()[source]

Update data widgets

updatePlot()[source]

Update the current plot with new options

updateStyle()[source]
updateWidgets()[source]

Set global widgets from values

venn(data, ax, colormap=None, alpha=0.8)[source]

Plot venn diagram, requires matplotlb-venn

violinplot(df, ax, kwds)[source]

violin plot

zoom(zoomin=True)[source]

Zoom in/out to plot by changing size of elements

class pandastable.plotting.TkOptions(parent=None)[source]

Bases: object

Class to generate tkinter widget dialog for dict of options

apply()[source]
applyOptions()[source]

Set the plot kwd arguments from the tk variables

increment(key, inc)[source]

Increase the value of a widget

setWidgetStyles()[source]
showDialog(parent, layout='horizontal')[source]

Auto create tk vars, widgets for corresponding options and and return the frame

updateFromDict(kwds=None)[source]

Update all widget tk vars using plot kwds dict

pandastable.plotting.addFigure(parent, figure=None, resize_callback=None)[source]

Create a tk figure and canvas in the parent frame

pandastable.plotting.get_defaults(name)[source]

pandastable.plugin module

Implements the dataexplore plugin class. Created Oct 2015 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.plugin.Plugin(parent=None)[source]

Bases: object

Base Plugin class, should be inherited by any plugin

capabilities = []
main(parent)[source]
menuentry = ''
quit(evt=None)[source]
requires = []
pandastable.plugin.describe_class(obj)[source]

Describe the class object passed as argument, including its methods

pandastable.plugin.describe_func(obj, method=False)[source]

Describe the function object passed as argument. If this is a method object, the second argument will be passed as True

pandastable.plugin.find_plugins()[source]
pandastable.plugin.get_plugins_classes(capability)[source]

Returns classes of available plugins

pandastable.plugin.get_plugins_instances(capability)[source]

Returns instances of available plugins

pandastable.plugin.init_plugin_system(folders)[source]
pandastable.plugin.load_plugins(plugins)[source]
pandastable.plugin.parsefolder(folder)[source]

Parse for all .py files in plugins folder or zip archive

pandastable.config module

Implements a configuration class for pandastable Created Oct 2015 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

pandastable.config.apply_options(options, table)[source]

Apply options to a table

pandastable.config.check_options(opts)[source]

Check for missing default options in dict. Meant to handle incomplete config files

pandastable.config.create_config_parser_from_dict(data=None, sections=odict_keys(['base', 'colors']), **kwargs)[source]

Helper method to create a ConfigParser from a dict of the form shown in baseoptions

pandastable.config.get_options(cp)[source]

Makes sure boolean opts are parsed

pandastable.config.load_options()[source]
pandastable.config.parse_config(conffile=None)[source]

Parse a configparser file

class pandastable.config.preferencesDialog(parent, options, table=None)[source]

Bases: tkinter.ttk.Frame

Preferences dialog from config parser options

apply()[source]

Apply options to current table

createWidgets()[source]

create widgets

quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

save()[source]

Save from current dialog settings

updateFromOptions(options)[source]

Update all widget tk vars using dict

pandastable.config.print_options(options)[source]

Print option key/value pairs

pandastable.config.update_config(options)[source]
pandastable.config.write_config(conffile='default.conf', defaults={})[source]

Write a default config file

pandastable.config.write_default_config()[source]

Write a default config to users .config folder. Used to add global settings.

pandastable.stats module

Module for stats and fitting classes.

Created June 2015 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

class pandastable.stats.StatsViewer(table, parent=None)[source]

Bases: tkinter.ttk.Frame

Provides a frame for model viewing interaction

doFit()[source]

Do model fit on selected subset of rows. Will only use the currently selected rows for fitting.

getModel(formula, data, est='ols')[source]

Select model to use

guessFormula()[source]

Suggest a start formula

plotLogit(fit, indvar, ax, **kwds)[source]

Plot Logit results

plotPrediction(fit, ax)[source]

Plot predicted vs. test

plotRegression(fit, indvar, ax, **kwds)[source]

Plot custom statsmodels fit result for linear regression

quit()[source]

Quit the Tcl interpreter. All widgets will be destroyed.

setupGUI()[source]

Add GUI elements

showPlot()[source]

Do plots

summary()[source]

Fit summary

updateData()[source]

Update data widgets

pandastable.tests module

pandastable.util module

Implements the utility methods for pandastable classes. Created August 2015 Copyright (C) Damien Farrell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

pandastable.util.adjustColorMap(cmap, minval=0.0, maxval=1.0, n=100)[source]

Adjust colormap to avoid using white in plots

pandastable.util.checkDict(d)[source]

Check a dict recursively for non serializable types

pandastable.util.checkOS()[source]

Check the OS we are in

pandastable.util.check_multiindex(index)[source]

Check if index is a multiindex

pandastable.util.colorScale(hex_color, brightness_offset=1)[source]

Takes a hex color and produces a lighter or darker variant. :returns: new color in hex format

pandastable.util.getAttributes(obj)[source]

Get non hidden and built-in type object attributes that can be persisted

pandastable.util.getFonts()[source]

Get the current list of system fonts

pandastable.util.getTextLength(text, w, font=None)[source]

Get correct canvas text size (chars) that will fit in a given canvas width

pandastable.util.setAttributes(obj, data)[source]

Set attributes from a dict. Used for restoring settings in tables

Module contents