### Install PandasTable from Source Source: https://pandastable.readthedocs.io/en/latest/description Installs PandasTable from its source distribution. This involves extracting the tar.gz file, navigating into the directory, and running the setup script. Dependencies must be installed separately. ```shell tar -xzvf pandastable.version.tar.gz cd pandastable sudo python3 setup.py install ``` -------------------------------- ### pandastable Installation Guide Source: https://pandastable.readthedocs.io/en/latest/index Instructions for installing the pandastable library and its associated Dataexplore application on different operating systems (Linux, Windows, Mac OSX). ```text Installation * For Dataexplore * pandastable library * Linux * Windows * Mac OSX ``` -------------------------------- ### Plugin Implementation Base (PandasTable) Source: https://pandastable.readthedocs.io/en/latest/examples Shows the fundamental structure for implementing a custom plugin for PandasTable. It involves subclassing the `Plugin` class and ensuring a `main()` method is present, which is called by the application to launch the plugin. The example includes getting the current table and adding a plugin frame. ```Python from pandastable.plugin import Plugin # ... inside a plugin class that inherits from Plugin ... def main(self): self.table = self.parent.getCurrentTable() #get the current table #add the plugin frame to the table parent self.mainwin = Frame(self.table.parentframe) #pluginrow is 6 to make the frame appear below other widgets self.mainwin.grid(row=pluginrow,column=0,columnspan=2,sticky='news') ``` -------------------------------- ### Setup Query Input and Filter Buttons in PandasTable Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs The `setup` method configures the user interface for the `QueryDialog`. It creates a label for entering the query, an Entry widget bound to a `StringVar` for input, and buttons for applying the filter and adding manual filters. It also includes frames to organize these widgets. ```Python def setup(self): qf = self sfont = "Helvetica 10 bold" Label(qf, text='Enter String Query:', font=sfont).pack(side=TOP,fill=X) self.queryvar = StringVar() e = Entry(qf, textvariable=self.queryvar, font="Courier 12 bold") e.bind('', self.query) e.pack(fill=BOTH,side=TOP,expand=1,padx=2,pady=2) self.fbar = Frame(qf) self.fbar.pack(side=TOP,fill=BOTH,expand=1,padx=2,pady=2) f = Frame(qf) f.pack(side=TOP, fill=BOTH, padx=2, pady=2) addButton(f, 'find', self.query, images.filtering(), 'apply filters', side=LEFT) addButton(f, 'add manual filter', self.addFilter, images.add(), 'add manual filter', side=LEFT) ``` -------------------------------- ### Install DataExplore on Linux Source: https://pandastable.readthedocs.io/en/latest/description This command installs the DataExplore application on Linux using snaps. It's a recommended method for Linux users. ```Shell snap install dataexplore ``` -------------------------------- ### Install pandastable Library Source: https://pandastable.readthedocs.io/en/latest/description This command installs the pandastable library and its dependencies using pip. Ensure pip is installed on your system before running this command. ```Python pip install pandastable ``` -------------------------------- ### pandastable Code Examples Source: https://pandastable.readthedocs.io/en/latest/index A collection of code examples demonstrating various functionalities of the pandastable library, including basics, subclassing the Table, table methods, direct data access and modification, setting attributes and preferences, table coloring, writing plugins, and freezing the application. ```text Code Examples * Basics * Sub-class the Table * Table methods * Accessing and modifying data directly * Set table attributes * Set Preferences * Table Coloring * Writing DataExplore Plugins * Freezing the app ``` -------------------------------- ### Launch a Basic Table Application Source: https://pandastable.readthedocs.io/en/latest/examples A complete example of a Tkinter application that includes a PandasTable. This class demonstrates how to set up the main window, create a frame, load sample data, and configure table options like toolbars and status bars. ```Python from tkinter import * from pandastable import Table, TableModel, config class TestApp(Frame): """Basic test frame for the table""" def __init__(self, parent=None): self.parent = parent Frame.__init__(self) self.main = self.master self.main.geometry('600x400+200+100') self.main.title('Table app') f = Frame(self.main) f.pack(fill=BOTH,expand=1) df = TableModel.getSampleData() self.table = pt = Table(f, dataframe=df, showtoolbar=True, showstatusbar=True) pt.show() #set some options options = {'colheadercolor':'green','floatprecision': 5} config.apply_options(options, pt) pt.show() return app = TestApp() #launch the app app.mainloop() ``` -------------------------------- ### Setup GUI Source: https://pandastable.readthedocs.io/en/latest/pandastable Initializes and adds graphical user interface elements to the plot. ```Python setupGUI() ``` -------------------------------- ### Freeze Tkinter App with cx_freeze (Python) Source: https://pandastable.readthedocs.io/en/latest/examples This snippet demonstrates the command to freeze a Tkinter application using the cx_freeze package and create a Windows MSI installer. It assumes the 'freeze.py' script is available in the project's root directory. ```python python freeze.py bdist_msi ``` -------------------------------- ### Custom PandasTable with Overridden Methods Source: https://pandastable.readthedocs.io/en/latest/examples Illustrates how to create a custom table class by subclassing the existing `Table` class. This example shows how to override methods like `handle_left_click` and `popupMenu` to add custom behavior, such as modifying the right-click context menu. ```Python class MyTable(Table): """Custom table class inherits from Table. You can then override required methods""" def __init__(self, parent=None, **kwargs): Table.__init__(self, parent, **kwargs) return def handle_left_click(self, event): """Example - override left click""" Table.handle_left_click(self, event) #do custom code here return def popupMenu(self, event, rows=None, cols=None, outside=None): """Custom right click menu""" popupmenu = Menu(self, tearoff = 0) def popupFocusOut(event): popupmenu.unpost() # add commands here # self.app is a reference to the parent app popupmenu.add_command(label='do stuff', command=self.app.stuff) popupmenu.bind("", popupFocusOut) popupmenu.focus_set() popupmenu.post(event.x_root, event.y_root) return popupmenu ``` -------------------------------- ### Install pandastable on Linux (apt) Source: https://pandastable.readthedocs.io/en/latest/description This command installs the matplotlib package, a dependency for pandastable, using the apt package manager on Debian/Ubuntu-based Linux distributions. It ensures the necessary components for matplotlib are available. ```Shell sudo apt install python-matplotlib ``` -------------------------------- ### Import CSV into PandasTable Source: https://pandastable.readthedocs.io/en/latest/examples Provides an example of how to import data from a CSV file into a PandasTable. This is a common operation for populating the table with external data. ```Python pt.importCSV('test.csv') ``` -------------------------------- ### PandasTable: Get Sample Data Source: https://pandastable.readthedocs.io/en/latest/genindex Loads a sample dataset as a class method within the TableModel. Useful for demonstrations. ```Python pandastable.data.TableModel.getSampleData() ``` -------------------------------- ### Install PandasTable Dependencies on MacPorts Source: https://pandastable.readthedocs.io/en/latest/description Installs pip for Python 3.4 and then uses pip to install matplotlib, numpy, pandas, and numexpr. This is a common setup for scientific Python on macOS using MacPorts. ```shell sudo port install py34-pip sudo pip-3.4 install matplotlib numpy pandas numexpr ``` -------------------------------- ### Launch DataExplore from Command Line Source: https://pandastable.readthedocs.io/en/latest/dataexplore Demonstrates how to launch the DataExplore application from the command line with various options. These options allow users to display help, open project files, load dataframes from messagepack files, import CSV files, or launch a basic test table. ```Shell dataexplore -h dataexplore -p dataexplore -f dataexplore -i dataexplore -t ``` -------------------------------- ### PandasTable: Get Iris Dataset Source: https://pandastable.readthedocs.io/en/latest/genindex Loads the Iris dataset as a class method within the TableModel. Useful for testing and examples. ```Python pandastable.data.TableModel.getIrisData() ``` -------------------------------- ### BaseDialog Initialization and Setup Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Initializes the BaseDialog class, setting up the main window, title, and protocols for window events. It also configures the window's geometry, grab behavior, and resizability. ```Python self.main = self.main x,y,w,h = getParentGeometry(self.parent) self.main.geometry('+%d+%d' %(x+w/2-200,y+h/2-200)) self.main.title(title) self.main.protocol("WM_DELETE_WINDOW", self.quit) self.main.grab_set() self.main.transient(parent) self.main.resizable(width=False, height=False) self.df = df self.result = None return ``` -------------------------------- ### Get Iris Dataset Source: https://pandastable.readthedocs.io/en/latest/pandastable A class method that loads and returns the well-known Iris dataset, commonly used for machine learning examples. ```Python @classmethod def getIrisData(cls): """Get iris dataset""" pass ``` -------------------------------- ### Set Multiple Selected Rows Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Sets the start and end rows for a selection, and populates a list with all selected rows. This is used when multiple rows are selected, for example, by clicking and dragging. ```Python def setSelectedRows(self, rows): self.startrow = rows[0] self.endrow = rows[-1] self.multiplerowlist = [] for r in rows: self.multiplerowlist.append(r) ``` -------------------------------- ### Load and Apply Table Preferences (PandasTable) Source: https://pandastable.readthedocs.io/en/latest/examples Explains how to load table preferences from a configuration file or set them programmatically. It shows how to use the `config` module to load options, modify them (e.g., `floatprecision`), and apply them to a table. ```Python #load from a config file if you need to (done by default when tables are created) options = config.load_options() #options is a dict that you can set yourself options = {'floatprecision': 2} config.apply_options(options, table) ``` -------------------------------- ### Get Visible Column Range Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Determines the starting and ending column numbers that are currently visible on the canvas. It utilizes the 'getColPosition' method to find the visible columns based on the provided x-coordinates. ```Python def getVisibleCols(self, x1, x2): """Get the visible column range""" start = self.getColPosition(x1) ``` -------------------------------- ### Get Visible Row Range Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Calculates the starting and ending row numbers that are currently visible on the canvas. It uses the 'getRowPosition' method to determine the visible rows based on the provided y-coordinates. ```Python def getVisibleRows(self, y1, y2): """Get the visible row range""" start = self.getRowPosition(y1) end = self.getRowPosition(y2)+1 if end > self.rows: end = self.rows return start, end ``` -------------------------------- ### Initialize PandasTable Plugin System Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/plugin Initializes the plugin system by adding specified folders to the Python path and loading plugins found within them. It returns a list of any plugins that failed to load. ```Python def init_plugin_system(folders): for folder in folders: if not os.path.exists(folder): continue if not folder in sys.path: sys.path.insert(0, folder) plugins = parsefolder(folder) #print (plugins) failed = load_plugins(plugins) return failed ``` -------------------------------- ### Get Column Position from X-coordinate Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Identifies the column number based on a given x-coordinate. It iterates through the column positions to find the column whose starting x-coordinate is less than or equal to the provided x-coordinate. ```Python def getColPosition(self, x): """Get column position at coord""" x_start = self.x_start w = self.cellwidth i=0 col=0 for c in self.col_positions: col = i if c+w>=x: break i+=1 return int(col) ``` -------------------------------- ### Get Row Position from Y-coordinate Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Determines the row number corresponding to a given y-coordinate. It calculates the row based on the row height and the starting y-position, ensuring the returned row is within the valid range. ```Python def getRowPosition(self, y): """Set row position""" h = self.rowheight y_start = self.y_start row = (int(y)-y_start)/h if row < 0: return 0 if row > self.rows: row = self.rows return int(row) ``` -------------------------------- ### PandasTable: Data Model and View Setup Source: https://pandastable.readthedocs.io/en/latest/genindex Methods related to setting up and managing the data model and views within the table. Includes functions for setting default preferences and managing data display. ```Python set_defaults() set_rowcolors_index() set_xviews() set_yviews() setup() setupGUI() setValueAt() setupGUI() ``` -------------------------------- ### Get Cell Coordinates Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Calculates the starting and ending x-y coordinates for drawing a specific cell. It uses the table's dimensions and the given row and column to determine the bounding box of the cell. ```Python def getCellCoords(self, row, col): """Get x-y coordinates to drawing a cell in a given row/col""" h = self.height/self.rows x_start=0 y_start=0 #get nearest rect co-ords for that row/col w = self.width/self.cols x1 = w*col y1=y_start+h*row x2=x1+w y2=y1+h return x1,y1,x2,y2 ``` -------------------------------- ### Get System Fonts using Matplotlib Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/util Retrieves a sorted list of unique system font names using Matplotlib's font management capabilities. It finds system fonts and then extracts their names. This function requires Matplotlib to be installed. ```Python [docs]def getFonts(): """Get the current list of system fonts""" import matplotlib.font_manager #l = matplotlib.font_manager.get_fontconfig_fonts() l = matplotlib.font_manager.findSystemFonts() fonts = [] for fname in l: try: fonts.append(matplotlib.font_manager.FontProperties(fname=fname).get_name()) except RuntimeError: pass fonts = list(set(fonts)) fonts.sort() #f = matplotlib.font_manager.FontProperties(family='monospace') #print (matplotlib.font_manager.findfont(f)) return fonts ``` -------------------------------- ### Setup TableModel Source: https://pandastable.readthedocs.io/en/latest/pandastable Configures the TableModel with a DataFrame and optional row and column counts. This is an alternative way to initialize or reconfigure the model. ```Python def setup(self, dataframe, rows=20, columns=5): """Create table model""" pass ``` -------------------------------- ### Get Persistable Object Attributes Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/util Retrieves attributes from an object that are not private (do not start with '_') and are of basic Python types (str, int, float, list, tuple, bool) or dictionaries containing only these types. This is used for persisting object settings. It recursively checks dictionaries for valid types. ```Python [docs]def getAttributes(obj): """Get non hidden and built-in type object attributes that can be persisted""" d={} allowed = [str,int,float,list,tuple,bool] for key in obj.__dict__: if key.startswith('_'): continue item = obj.__dict__[key] if type(item) in allowed: d[key] = item elif type(item) is dict: if checkDict(item) == 1: d[key] = item return d ``` -------------------------------- ### Initialize Toolbar Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Initializes the ToolBar widget, setting up its parent frame and application instance. It then adds various buttons with associated functions and images for common operations like loading, saving, importing, exporting, copying, pasting, plotting, transposing, aggregating, pivoting, and melting data. ```Python class ToolBar(Frame): """Uses the parent instance to provide the functions""" def __init__(self, parent=None, parentapp=None): Frame.__init__(self, parent, width=600, height=40) self.parentframe = parent self.parentapp = parentapp img = images.open_proj() addButton(self, 'Load table', self.parentapp.load, img, 'load table') img = images.save_proj() addButton(self, 'Save', self.parentapp.save, img, 'save') img = images.importcsv() func = lambda: self.parentapp.importCSV(dialog=1) addButton(self, 'Import', func, img, 'import csv') img = images.excel() addButton(self, 'Load excel', self.parentapp.loadExcel, img, 'load excel file') img = images.copy() addButton(self, 'Copy', self.parentapp.copyTable, img, 'copy table to clipboard') img = images.paste() addButton(self, 'Paste', self.parentapp.paste, img, 'paste table') img = images.plot() addButton(self, 'Plot', self.parentapp.plotSelected, img, 'plot selected') img = images.transpose() addButton(self, 'Transpose', self.parentapp.transpose, img, 'transpose') img = images.aggregate() addButton(self, 'Aggregate', self.parentapp.aggregate, img, 'aggregate') img = images.pivot() addButton(self, 'Pivot', self.parentapp.pivot, img, 'pivot') img = images.melt() addButton(self, 'Melt', self.parentapp.melt, img, 'melt') ``` -------------------------------- ### pandastable Package Overview Source: https://pandastable.readthedocs.io/en/latest/index Information about the pandastable package itself, likely covering its structure and core components. ```text pandastable * pandastable package ``` -------------------------------- ### Start Animation Thread Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/plotting This method starts an animation loop by creating and starting a new thread that targets the 'update' method. It prevents multiple threads from running simultaneously by checking a 'running' flag. Dependencies include the 'threading' module. ```Python from threading import Thread def start(self): """start animation using a thread""" if self.running == True: return self.stopthread = False self.running = True t = Thread(target=self.update) t.start() self.thread = t return ``` -------------------------------- ### FindReplaceDialog Setup Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Initializes a Find/Replace dialog for a table, setting up the parent frame, table reference, and internal state for tracking search results. ```Python class FindReplaceDialog(Frame): """Find/replace dialog.""" def __init__(self, table): parent = table.parentframe Frame.__init__(self, parent) self.parent = parent self.table = table self.coords = [] self.current = 0 #coords of found cells self.setup() return def setup(self): sf = self sfont = "Helvetica 10 bold" Label(sf, text='Enter Search String:', font=sfont).pack(side=TOP,fill=X) ``` -------------------------------- ### Get Sample Data Source: https://pandastable.readthedocs.io/en/latest/pandastable Generates a sample pandas DataFrame with a specified number of rows, columns, and length for column names. Useful for testing or demonstration purposes. ```Python @classmethod def getSampleData(cls, rows=400, cols=5, n=2): """Generate sample data :param rows: no. of rows :param cols: columns :param n: length of column names""" pass ``` -------------------------------- ### Create and Show a Basic PandasTable Source: https://pandastable.readthedocs.io/en/latest/examples Demonstrates how to create a basic table widget within a Tkinter frame and display it. It requires importing the necessary classes from tkinter and pandastable. ```Python from tkinter import * from pandastable import Table #assuming parent is the frame in which you want to place the table pt = Table(parent) pt.show() ``` -------------------------------- ### Get Selected Cell Values in PandasTable Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core This function retrieves the values from the currently selected cells in the PandasTable. It checks if there are any selected rows or columns before proceeding to get the values. ```Python def getSelectionValues(self): """Get values for current multiple cell selection""" if len(self.multiplerowlist) == 0 or len(self.multiplecollist) == 0: return ``` -------------------------------- ### Install 'future' package for Python 2.7 Source: https://pandastable.readthedocs.io/en/latest/description This command installs the 'future' package, which is required for Python 2.7 compatibility with pandastable. It ensures that Python 2.7 can utilize the library's features. ```Python pip install future ``` -------------------------------- ### Initialize and Show StatsViewer Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Initializes and displays the StatsViewer dialog for model fitting. It checks if the 'statsmodels' library is installed and creates a StatsViewer instance if it doesn't exist. ```Python def statsViewer(self): """Show model fitting dialog""" from .stats import StatsViewer self.showPlotViewer() if StatsViewer._doimport() == 0: messagebox.showwarning("no such module", "statsmodels is not installed.", parent=self.parentframe) return if not hasattr(self, 'sv') or self.sv == None: sf = self.statsframe = Frame(self.parentframe) sf.grid(row=self.queryrow+1,column=0,columnspan=3,sticky='news') self.sv = StatsViewer(table=self,parent=sf) return self.sv ``` -------------------------------- ### Configuration and Plugin Management in PandasTable Source: https://pandastable.readthedocs.io/en/latest/genindex This snippet covers methods for managing the configuration and plugin system of PandasTable. It includes functions for loading preferences, options, and plugins. ```python load_options() load_plugins() init_plugin_system() ``` -------------------------------- ### Load Preferences Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Loads user preferences from configuration files and applies them to the application. It utilizes a configuration loading mechanism to set up application options. ```Python def loadPrefs(self, prefs=None): """Load preferences from defaults""" options = config.load_options() config.apply_options(options, self) return ``` -------------------------------- ### Get Rows from Boolean Mask Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Retrieves row positions from a boolean mask applied to the DataFrame. It first finds the index values corresponding to the mask and then uses getRowsFromIndex to get their positions. ```Python def getRowsFromMask(self, mask): df = self.model.df if mask is not None: idx = df.ix[mask].index return self.getRowsFromIndex(idx) ``` -------------------------------- ### PandasTable: Dialog and Utility Functions Source: https://pandastable.readthedocs.io/en/latest/genindex Includes functions for managing dialogs, such as progress indicators, color pickers, and find/replace dialogs. Also covers configuration parsing and plugin functionalities. ```Python from pandastable.dialogs import Progress, AutoScrollbar, FindReplaceDialog, CombineDialog, AggregateDialog, BaseDialog, ImportDialog, BaseTable, QueryDialog from pandastable.config import preferencesDialog from pandastable.plugin import Plugin # Example usage for pack from pandastable.dialogs import AutoScrollbar scrollbar = AutoScrollbar() scrollbar.pack() # Example usage for pickColor from pandastable.dialogs import pickColor color = pickColor() # Example usage for place scrollbar.place(x, y) # Example usage for placeColumn table = Table() table.placeColumn(col_index, x_position) # Example usage for popupMenu table.popupMenu() # Example usage for quit pref_dialog = preferencesDialog() pref_dialog.quit() # Example usage for parse_config from pandastable.config import parse_config config = parse_config('config.json') # Example usage for parsefolder from pandastable.plugin import parsefolder parsed_data = parsefolder('/path/to/folder') # Example usage for paste from pandastable.images import paste paste() # Example usage for pivot table.pivot(index_col, columns_col, values_col) # Example usage for pb_start, pb_stop, pb_clear, pb_complete progress = Progress() progress.pb_start(total_steps) progress.pb_complete() progress.pb_clear() progress.pb_stop() # Example usage for replace find_replace_dialog = FindReplaceDialog(table) find_replace_dialog.replace("find_text", "replace_text") # Example usage for replaceTable combine_dialog = CombineDialog(table) combine_dialog.replaceTable(other_table) # Example usage for reset from pandastable.plotting import ExtraOptions extra_options = ExtraOptions() extra_options.reset() # Example usage for resetGrid from pandastable.plotting import PlotLayoutOptions plot_layout_options = PlotLayoutOptions() plot_layout_options.resetGrid() # Example usage for requires attribute plugin = Plugin() requires_info = plugin.requires ``` -------------------------------- ### Open Pandas GroupBy Help Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Opens a web browser to the official Pandas documentation page for groupby operations. This provides users with detailed information and examples for using the groupby functionality. ```Python def help(self): link='http://pandas.pydata.org/pandas-docs/stable/groupby.html' webbrowser.open(link,autoraise=1) return ``` -------------------------------- ### TkOptions Class Initialization Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/plotting Initializes the TkOptions class, setting up the parent widget and retrieving the DataFrame model. ```Python class TkOptions(object): """Class to generate tkinter widget dialog for dict of options""" def __init__(self, parent=None): """Setup variables""" self.parent = parent df = self.parent.table.model.df return ``` -------------------------------- ### Access and Modify Pandas DataFrame in Table Source: https://pandastable.readthedocs.io/en/latest/examples Explains how to access and modify the underlying pandas DataFrame within a PandasTable. It highlights that changes to the DataFrame require calling `table.redraw()` to be reflected in the table view. Examples include dropping columns and transposing the DataFrame. ```Python df = table.model.df #Examples of simple dataframe operations. Remember when you update the dataframe you will need to call table.redraw() to see the changes reflected: df.drop(0) #delete column with this index df.T #transpose the DataFrame df.drop(columns=['x']) ``` -------------------------------- ### CrosstabDialog Help Method Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Opens a web browser to the pandas.crosstab documentation page. ```Python def help(self): link='https://pandas.pydata.org/pandas-docs/stable/generated/pandas.crosstab.html' webbrowser.open(link,autoraise=1) return ``` -------------------------------- ### Pandastable Configuration Management Source: https://pandastable.readthedocs.io/en/latest/pandastable Provides functionality for managing Pandastable's configuration, including applying options to tables, checking configuration validity, parsing configuration files, and creating default configuration files. It also includes a preferences dialog for user interaction. ```Python def pandastable.config.apply_options(options, table): """Apply options to a table""" pass def pandastable.config.check_options(opts): """Check for missing default options in dict. Meant to handle incomplete config files""" pass def pandastable.config.create_config_parser_from_dict(data=None, sections=odict_keys(['base', 'colors']), **kwargs): """Helper method to create a ConfigParser from a dict of the form shown in baseoptions""" pass def pandastable.config.get_options(cp): """Makes sure boolean opts are parsed""" pass def pandastable.config.load_options(): pass def pandastable.config.parse_config(conffile=None): """Parse a configparser file""" pass def pandastable.config.print_options(options): """Print option key/value pairs""" pass def pandastable.config.update_config(options): pass def pandastable.config.write_config(conffile='default.conf', defaults={}): """Write a default config file""" pass def pandastable.config.write_default_config(): """Write a default config to users .config folder. Used to add global settings.""" pass class pandastable.config.preferencesDialog(tkinter.ttk.Frame): """Preferences dialog from config parser options""" def apply(self): """Apply options to current table""" pass def createWidgets(self): """create widgets""" pass def quit(self): """Quit the Tcl interpreter. All widgets will be destroyed.""" pass def save(self): """Save from current dialog settings""" pass def updateFromOptions(self, options): """Update all widget tk vars using dict""" pass ``` -------------------------------- ### pandastable DataExplore Usage Source: https://pandastable.readthedocs.io/en/latest/index Guide to using the DataExplore application, covering its purpose, table layout, command-line operations, data import/export, data cleaning, string operations, summarization, merging, pivoting, transposing, filtering, applying functions, column conversion, resampling, and plotting options. ```text Using DataExplore * Purpose of the program * Table layout * Command Line * Import text files * Saving data * Getting table info * Cleaning data * String operations * Summarizing and grouping data * Merging two tables * Pivoting tables * Transpose tables * Filtering tables * Applying functions * Converting column names * Resampling columns * Plot options * Plotting grouped data * Plotting in a grid * Animated plots * Table Coloring * Setting preferences * Batch processing * Other examples ``` -------------------------------- ### Get Colormap Source: https://pandastable.readthedocs.io/en/latest/pandastable Retrieves a colormap by its name. ```Python getcmap(_name_) ``` -------------------------------- ### Get Row Count (Python) Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/data Returns the total number of rows in the DataFrame. ```Python def getRowCount(self): """Returns the number of rows in the table model.""" return len(self.df) ``` -------------------------------- ### PandasTable Describe Source: https://pandastable.readthedocs.io/en/latest/pandastable Generates and displays a summary description of the table's data. ```Python def describe(): """Create table summary""" pass ``` -------------------------------- ### Get Column Count (Python) Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/data Returns the total number of columns in the DataFrame. ```Python def getColumnCount(self): """Returns the number of columns in the data model""" return len(self.df.columns) ``` -------------------------------- ### Initialize QueryDialog for Filtering in PandasTable Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs This class, `QueryDialog`, is designed to allow users to filter table data using string queries. It inherits from `Frame` and takes a `table` object as input. The `__init__` method sets up the parent frame, table reference, and calls the `setup` method to create the UI elements for entering and applying queries. ```Python class QueryDialog(Frame): """Use string query to filter. Will not work with spaces in column names, so these would need to be converted first.""" def __init__(self, table): parent = table.parentframe Frame.__init__(self, parent) self.parent = parent self.table = table self.setup() self.filters = [] return ``` -------------------------------- ### Get Column Type (Python) Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/data Retrieves the data type of a column specified by its index. ```Python def getColumnType(self, columnIndex): """Get the column type""" coltype = self.df.dtypes[columnIndex] return coltype ``` -------------------------------- ### Pandastable Plugin Base Class and Utilities Source: https://pandastable.readthedocs.io/en/latest/pandastable Defines the base Plugin class for Pandastable extensions and provides utility functions for describing classes and functions, as well as managing the plugin system. It includes methods for finding, loading, and initializing plugins. ```Python class pandastable.plugin.Plugin(parent=None): """Base Plugin class, should be inherited by any plugin""" capabilities = [] menuentry = '' requires = [] def main(parent): pass def quit(evt=None): pass def pandastable.plugin.describe_class(obj): """Describe the class object passed as argument, including its methods""" pass def pandastable.plugin.describe_func(obj, method=False): """Describe the function object passed as argument. If this is a method object, the second argument will be passed as True""" pass def pandastable.plugin.find_plugins(): pass def pandastable.plugin.get_plugins_classes(capability): """Returns classes of available plugins""" pass def pandastable.plugin.get_plugins_instances(capability): """Returns instances of available plugins""" pass def pandastable.plugin.init_plugin_system(folders): pass def pandastable.plugin.load_plugins(plugins): pass def pandastable.plugin.parsefolder(folder): """Parse for all .py files in plugins folder or zip archive""" pass ``` -------------------------------- ### Get Record at Row (Python) Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/data Retrieves the entire record (row) from the DataFrame at a specified row index. ```Python def getRecordAtRow(self, rowindex): """Get the entire record at the specifed row""" record = self.df.iloc[rowindex] return record ``` -------------------------------- ### Combine Dialog Initialization Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Initializes the CombineDialog frame, setting up the main window, title, and protocols for merge/join/concat operations. It prepares the UI for selecting operation types and parameters. ```Python class CombineDialog(Frame): """Provides a frame for setting up merge/combine operations""" def __init__(self, parent=None, df1=None, df2=None): self.parent = parent self.main = Toplevel() self.master = self.main self.main.title('Merge/Join/Concat') self.main.protocol("WM_DELETE_WINDOW", self.quit) self.main.grab_set() self.main.transient(parent) self.main.resizable(width=False, height=False) self.df1 = df1 self.df2 = df2 self.merged = None wf = Frame(self.main) wf.pack(side=LEFT,fill=BOTH) f=Frame(wf) f.pack(side=TOP,fill=BOTH) ops = ['merge','concat'] self.opvar = StringVar() w = Combobox(f, values=ops, textvariable=self.opvar,width=14 ) w.set('merge') Label(f,text='operation:').pack() w.pack() #buttons to add for each op. #merge: left, right, how, suff1, suff2 #concat assumes homogeneous dfs how = ['inner','outer','left','right'] grps = {'merge': ['left_on','right_on','suffix1','suffix2','how'], ``` -------------------------------- ### Get Currently Selected Column Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Retrieves and returns the index of the currently selected column in the table. ```Python def getSelectedColumn(self): """Get currently selected column""" return self.currentcol ``` -------------------------------- ### Load Options from Configuration File Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/config This function loads options from a configuration file. If the default configuration file does not exist, it creates one. It then parses the configuration and retrieves the options, performing a check for any missing options. ```Python def load_options(): if not os.path.exists(default_conf): write_config(default_conf, defaults=baseoptions) cp = parse_config(default_conf) options = get_options(cp) options = check_options(options) return options ``` -------------------------------- ### PandasTable String Filtering Examples Source: https://pandastable.readthedocs.io/en/latest/dataexplore Demonstrates how to filter data in PandasTable using string-based queries, including comparisons, substring containment, and length checks. ```Python x>4 and y<3 #filter by values of columns x and y ``` ```Python x.str.contains("abc") #find only values of column x containing substring #abc ``` ```Python x.str.len()>3 #find only rows where length of strings in x is greater than 3 ``` -------------------------------- ### Get Currently Selected Row Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Retrieves and returns the index of the currently selected row in the table. ```Python def getSelectedRow(self): """Get currently selected row""" return self.currentrow ``` -------------------------------- ### Get Default Plot Options Source: https://pandastable.readthedocs.io/en/latest/pandastable Retrieves the default options for a specified plot type. ```Python get_defaults(_name_) ``` -------------------------------- ### PandasTable: Get Colormap Source: https://pandastable.readthedocs.io/en/latest/genindex Retrieves the colormap used in the PlotViewer. This method is part of the pandastable.plotting.PlotViewer class. ```Python plot_viewer.getcmap() ``` -------------------------------- ### PandasTable: Create Dialog and Widget Functions Source: https://pandastable.readthedocs.io/en/latest/genindex This snippet covers functions related to creating dialogs and widgets, including `createChildTable()` from `pandastable.core.Table`, `createSubMenu()` from `pandastable.headers`, `createToolTip()` (class method) from `pandastable.dialogs.ToolTip`, and `createWidgets()` from `pandastable.config.preferencesDialog` and other dialog classes. ```Python from pandastable.core import Table from pandastable.headers import createSubMenu from pandastable.dialogs import ToolTip, AggregateDialog, BaseDialog, CrosstabDialog from pandastable.config import preferencesDialog # Example usage (assuming instances exist): # table_instance = Table() # table_instance.createChildTable() # createSubMenu() # ToolTip.createToolTip() # preferencesDialog.createWidgets() # aggregate_dialog_instance = AggregateDialog() # aggregate_dialog_instance.createWidgets() # base_dialog_instance = BaseDialog() # base_dialog_instance.createWidgets() # crosstab_dialog_instance = CrosstabDialog() # crosstab_dialog_instance.createWidgets() ``` -------------------------------- ### Get Frame Geometry Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Retrieves the geometry (x, y coordinates, width, and height) of a given frame widget. ```Python def getGeometry(self, frame): """Get frame geometry""" return frame.winfo_rootx(), frame.winfo_rooty(), frame.winfo_width(), frame.winfo_height() ``` -------------------------------- ### Initialize TableModel Fields Source: https://pandastable.readthedocs.io/en/latest/pandastable Sets up the internal metadata fields required for the TableModel's operation. This is typically called during initialization or setup. ```Python def initialiseFields(self): """Create meta data fields""" pass ``` -------------------------------- ### PandasTable: Get Fonts Source: https://pandastable.readthedocs.io/en/latest/genindex Retrieves available font settings for the table. This method is available in pandastable.util and pandastable.core.Table. ```Python pandastable.util.getFonts() # or table.getFonts() ``` -------------------------------- ### Get Memory Usage Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/core Calculates and returns the memory usage of the current DataFrame. This is useful for monitoring resource consumption. ```Python def get_memory(self, ): """memory usage of current table""" df = self.model.df return df.memory_usage() ``` -------------------------------- ### Create Generic Dialog Frame Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/dialogs Initializes a generic dialog frame, setting up the parent window and a top-level window for the dialog. This serves as a base class for more specific dialogs. ```Python class BaseDialog(Frame): """Generic dialog - inherit from this and customise the createWidgets and apply methods.""" def __init__(self, parent=None, df=None, title=''): self.parent = parent self.main = Toplevel() ``` -------------------------------- ### MPLBaseOptions Class Initialization Source: https://pandastable.readthedocs.io/en/latest/_modules/pandastable/plotting Initializes the MPLBaseOptions class, inheriting from TkOptions. It sets up default options and configurations for various Matplotlib plot types. ```Python class MPLBaseOptions(TkOptions): """Class to provide a dialog for matplotlib options and returning the selected prefs""" 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'] defaultfont = 'monospace' def __init__(self, parent=None): """Setup variables""" self.parent = parent if self.parent is not None: df = self.parent.table.model.df datacols = list(df.columns) datacols.insert(0,'') else: datacols=[] fonts = util.getFonts() scales = ['linear','log'] grps = {'data':['by','by2','labelcol','pointsizes'], 'formats':['font','marker','linestyle','alpha'], 'sizes':['fontsize','ms','linewidth'], 'general':['kind','bins','stacked','subplots','use_index','errorbars'], 'axes':['grid','legend','showxlabels','showylabels','sharex','sharey','logx','logy'], 'colors':['colormap','bw','clrcol','cscale','colorbar']} order = ['general','data','axes','sizes','formats','colors'] self.groups = OrderedDict((key, grps[key]) for key in order) opts = self.opts = {'font':{'type':'combobox','default':self.defaultfont,'items':fonts}, 'fontsize':{'type':'scale','default':12,'range':(5,40),'interval':1,'label':'font size'}, 'marker':{'type':'combobox','default':'','items': markers}, 'linestyle':{'type':'combobox','default':'-','items': linestyles}, 'ms':{'type':'scale','default':5,'range':(1,80),'interval':1,'label':'marker size'}, 'grid':{'type':'checkbutton','default':0,'label':'show grid'}, 'logx':{'type':'checkbutton','default':0,'label':'log x'}, 'logy':{'type':'checkbutton','default':0,'label':'log y'}, #'rot':{'type':'entry','default':0, 'label':'xlabel angle'}, 'use_index':{'type':'checkbutton','default':1,'label':'use index'} ``` -------------------------------- ### Get Row Count Source: https://pandastable.readthedocs.io/en/latest/pandastable Returns the total number of rows currently present in the TableModel's data. ```Python def getRowCount(self): """Returns the number of rows in the table model.""" pass ```