### Basic Example Notebook Integration Source: https://plottable.readthedocs.io/en/latest/_sources/notebooks/table.ipynb.txt Link to the basic example notebook for Plottable. No specific setup is required to view this example. ```python You can find an example in the [Basic Example Notebook](../example_notebooks/basic_example.ipynb) ``` -------------------------------- ### Machine Learning Model Training (Scikit-learn) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Basic example of training a machine learning model using scikit-learn. Requires scikit-learn to be installed. ```python from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression X = df[['col0', 'col1']] y = df['col2'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) model = LinearRegression() model.fit(X_train, y_train) ``` -------------------------------- ### Install Plottable Source: https://plottable.readthedocs.io/en/latest/_sources/index.rst.txt Use pip to install the plottable library. This is the first step before using any of its features. ```bash pip install plottable ``` -------------------------------- ### Data Visualization Setup Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Initializes a Plotly figure and adds a table trace. This is the starting point for creating interactive tables. ```python import plotly.graph_objects as go fig = go.Figure() fig.add_trace(go.Table( header=dict(values=list(df.columns), fill_color='paleturquoise', align='left'), cells=dict(values=[df[col] for col in df.columns], fill_color='lavender', align='left')) ) ``` -------------------------------- ### Pie Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Illustrates how to create a pie chart. Suitable for showing proportions of a whole. ```python import matplotlib.pyplot as plt labels = ['Frogs', 'Hogs', 'Dogs', 'Logs'] sizes = [15, 30, 45, 10] fig, ax = plt.subplots() ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90) ax.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. plt.title('Pie Chart Example') plt.show() ``` -------------------------------- ### Basic Plotting with Plotly Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of creating a simple static plot using Plotly's graph objects. Ensure Plotly is installed. ```python import plotly.graph_objects as go import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) fig = go.Figure( data=go.Scatter(x=x, y=y, mode='lines', name='Sine Wave'), layout=go.Layout( title='Simple Plotly Static Plot', xaxis_title='X-axis', yaxis_title='Y-axis' ) ) # To display in notebook or save: # fig.show() # fig.write_html('plotly_static_plot.html') fig.show() ``` -------------------------------- ### 3D Plotting Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a 3D surface plot. Requires the `mpl_toolkits.mplot3d` toolkit. ```python from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.arange(-5, 5, 0.25) y = np.arange(-5, 5, 0.25) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) ax.plot_surface(X, Y, Z, cmap='viridis') ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') plt.title('3D Surface Plot') plt.show() ``` -------------------------------- ### Basic Plotting with Altair Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of creating a simple interactive line plot using the Altair declarative visualization library. Ensure Altair and Pandas are installed. ```python import altair as alt import pandas as pd import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) df = pd.DataFrame({'x': x, 'y': y}) chart = alt.Chart(df).mark_line().encode( x='x', y='y', tooltip=['x', 'y'] ).properties( title='Simple Altair Line Plot' ) # To save the chart: # chart.save('altair_line_plot.html') chart.show() ``` -------------------------------- ### Heatmap Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a heatmap to visualize matrix data. Requires NumPy and Matplotlib. ```python import matplotlib.pyplot as plt import numpy as np # Generate some random data for the heatmap data = np.random.rand(10, 12) plt.figure(figsize=(10, 8)) plt.imshow(data, cmap='hot', interpolation='nearest') plt.title('Heatmap Example') plt.colorbar(label='Value') plt.show() ``` -------------------------------- ### Create a Basic Table with Plottable Source: https://plottable.readthedocs.io/en/latest/_sources/index.rst.txt This example demonstrates how to create a simple table using Plottable with a Pandas DataFrame. Ensure you have matplotlib, numpy, and pandas installed. ```python import matplotlib.pyplot as plt import numpy as np import pandas as pd from plottable import Table d = pd.DataFrame(np.random.random((10, 5)), columns=["A", "B", "C", "D", "E"])).round(2) fig, ax = plt.subplots(figsize=(5, 8)) tab = Table(d) plt.show() ``` -------------------------------- ### Pie Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to create a pie chart to represent proportions of a whole. Requires Matplotlib. ```python import matplotlib.pyplot as plt labels = ['Frogs', 'Hogs', 'Dogs', 'Logs'] sizes = [15, 30, 45, 10] plt.figure(figsize=(8, 8)) plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140) plt.title('Pie Chart Example') plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. plt.show() ``` -------------------------------- ### Install Plottable in Editable Mode Source: https://plottable.readthedocs.io/en/latest/dev/contributing.html Use this command to set up an editable installation of Plottable for development. This allows you to make changes to the code and see them reflected immediately without reinstalling. ```bash git clone https://github.com/znstrider/plottable.git cd plottable pip install -e . ``` -------------------------------- ### Pie Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates how to create a pie chart to show proportions of a whole. Requires Matplotlib. ```python import matplotlib.pyplot as plt labels = ['Frogs', 'Hogs', 'Dogs', 'Logs'] sizes = [15, 30, 45, 10] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.figure(figsize=(8, 8)) plt.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90) plt.title('Pie Chart Example') plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. plt.show() ``` -------------------------------- ### Histogram Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates the creation of a histogram. Useful for understanding the distribution of a single variable. ```python import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.hist(data, bins=30, edgecolor='black') plt.xlabel('Value') plt.ylabel('Frequency') plt.title('Histogram of Random Data') plt.show() ``` -------------------------------- ### Basic Plotting Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates a fundamental plotting operation. Ensure necessary libraries are imported. ```python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig, ax = plt.subplots() ax.plot(x, y) ax.set_title('A simple line plot') plt.show() ``` -------------------------------- ### Histogram Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to generate a histogram to display the distribution of a dataset. Requires NumPy and Matplotlib. ```python import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.figure(figsize=(10, 5)) plt.hist(data, bins=30, density=True, alpha=0.7, color='g') plt.title('Histogram of Random Data') plt.xlabel('Value') plt.ylabel('Frequency') plt.grid(True) plt.show() ``` -------------------------------- ### Bar Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to generate a bar chart. Suitable for comparing quantities across different categories. ```python import matplotlib.pyplot as plt labels = ['A', 'B', 'C', 'D'] values = [10, 25, 15, 30] fig, ax = plt.subplots() ax.bar(labels, values) ax.set_ylabel('Values') ax.set_title('Simple Bar Chart') plt.show() ``` -------------------------------- ### Bar Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a bar chart for comparing categorical data. Requires Matplotlib. ```python import matplotlib.pyplot as plt categories = ['A', 'B', 'C', 'D', 'E'] values = [23, 45, 56, 12, 39] plt.figure(figsize=(8, 6)) plt.bar(categories, values, color='lightcoral') plt.title('Bar Chart Example') plt.xlabel('Category') plt.ylabel('Value') plt.grid(axis='y', alpha=0.75) plt.show() ``` -------------------------------- ### Create and Display a Matplotlib Table Source: https://plottable.readthedocs.io/en/latest/plottable.html This example demonstrates how to create a basic Table object from a pandas DataFrame and display it using matplotlib. Ensure you have pandas, numpy, and matplotlib installed. ```python import matplotlib.pyplot as plt import numpy as np import pandas as pd from plottable import Table d = pd.DataFrame(np.random.random((10, 5)), columns=["A", "B", "C", "D", "E"]).round(2) fig, ax = plt.subplots(figsize=(5, 8)) tab = Table(d) plt.show() ``` -------------------------------- ### Histogram Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to generate a histogram to display the distribution of a dataset. Requires NumPy and Matplotlib. ```python import matplotlib.pyplot as plt import numpy as np data = np.random.randn(1000) plt.figure(figsize=(8, 6)) plt.hist(data, bins=30, color='skyblue', edgecolor='black') plt.title('Histogram of Random Data') plt.xlabel('Value') plt.ylabel('Frequency') plt.grid(axis='y', alpha=0.75) plt.show() ``` -------------------------------- ### Basic Plotting with Matplotlib Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates fundamental plotting using Matplotlib. Ensure Matplotlib is installed. ```python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) plt.figure(figsize=(8, 6)) plt.plot(x, y, label='sin(x)') plt.title('Sine Wave Plot') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.legend() plt.grid(True) plt.show() ``` -------------------------------- ### Basic Plotting with Matplotlib Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates fundamental plotting using Matplotlib. Ensure Matplotlib is installed. ```python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2*np.pi, 400) y = np.sin(x**2) plt.figure(figsize=(10, 5)) plt.plot(x, y) plt.title('Simple Plot') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.grid(True) plt.show() ``` -------------------------------- ### Basic Table Creation in Matplotlib Source: https://plottable.readthedocs.io/en/latest/index.html A fundamental example demonstrating how to create a simple table from a Pandas DataFrame using plottable and display it with Matplotlib. Ensure you have pandas, numpy, and matplotlib installed. ```python import matplotlib.pyplot as plt import numpy as np import pandas as pd from plottable import Table d = pd.DataFrame(np.random.random((10, 5)), columns=["A", "B", "C", "D", "E"]).round(2) fig, ax = plt.subplots(figsize=(5, 8)) tab = Table(d) plt.show() ``` -------------------------------- ### Bar Chart Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Illustrates the creation of a bar chart for comparing categorical data. Requires Matplotlib. ```python import matplotlib.pyplot as plt categories = ['A', 'B', 'C', 'D', 'E'] values = [23, 45, 56, 12, 39] plt.figure(figsize=(10, 5)) plt.bar(categories, values, color='skyblue') plt.title('Bar Chart Example') plt.xlabel('Category') plt.ylabel('Value') plt.show() ``` -------------------------------- ### Table Example with Plots Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Generates a table with integrated plots, demonstrating how to use plottable's plotting functions within a pandas DataFrame. This example requires sample data to be defined. ```python df = pd.DataFrame( { "name": ["A", "B", "C", "D"], "score1": [0.1, 0.3, 0.8, 0.9], "score2": [0.2, 0.4, 0.7, 0.8], "score3": [0.5, 0.6, 0.3, 0.2], "score4": [0.9, 0.7, 0.4, 0.1], } ) # Define column properties including plot types and formatting cd = [ ColumnDefinition("name", width=200), ColumnDefinition("score1", data_type=float, formatter=decimal_to_percent, plot=bar(cmap=cmap)), ColumnDefinition("score2", data_type=float, formatter=decimal_to_percent, plot=percentile_bars(cmap=cmap)), ColumnDefinition("score3", data_type=float, formatter=decimal_to_percent, plot=percentile_stars(cmap=cmap)), ColumnDefinition("score4", data_type=float, formatter=decimal_to_percent, plot=progress_donut(cmap=cmap)), ] # Create and display the table with plots table = Table(df, column_definitions=cd) table.show() ``` -------------------------------- ### Image Path and Colormap Setup Source: https://plottable.readthedocs.io/en/latest/notebooks/plots.html Sets up an image path and a custom colormap for use in plots. This code is typically run once before generating plots. ```python path = list(Path("../example_notebooks/country_flags").glob("*.png"))[0] cmap = LinearSegmentedColormap.from_list( name="bugw", colors=["#ffffff", "#f2fbd2", "#c9ecb4", "#93d3ab", "#35b0ab"], N=256 ) ``` -------------------------------- ### Create a Simple Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Creates a basic table from a list of lists. This is a fundamental data structure example. ```python data = [ ['Alice', 25, 'New York'], ['Bob', 30, 'San Francisco'], ['Charlie', 35, 'Los Angeles'] ] columns = ['Name', 'Age', 'City'] table = pd.DataFrame(data, columns=columns) ``` -------------------------------- ### Basic Plotting with Bokeh Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a simple interactive line plot using the Bokeh library. Ensure Bokeh is installed. ```python from bokeh.plotting import figure, show from bokeh.io import output_notebook # Use output_file for saving to HTML import numpy as np # output_notebook() # Uncomment to display in Jupyter Notebook x = np.linspace(0, 10, 100) y = np.sin(x) p = figure(title="Simple Bokeh Line Plot", x_axis_label='X-axis', y_axis_label='Y-axis') p.line(x, y, legend_label="Sine Wave", line_width=2) # To save to HTML file: # from bokeh.io import output_file # output_file("simple_plot.html") show(p) ``` -------------------------------- ### Heatmap Example with Seaborn Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Illustrates how to create a heatmap to visualize matrix-like data using Seaborn. Requires Seaborn, Matplotlib, and NumPy. ```python import seaborn as sns import matplotlib.pyplot as plt import numpy as np data = np.random.rand(10, 12) sns.set_theme(style="whitegrid") plt.figure(figsize=(10, 8)) sns.heatmap(data, annot=True, fmt=".2f", cmap="viridis") plt.title('Seaborn Heatmap') plt.show() ``` -------------------------------- ### Heatmap with Data from Google Sheets Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Shows how to access data from a Google Sheet (requires setup and authentication) and visualize it as a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import gspread # Authenticate and open the sheet # gc = gspread.service_account(filename='path/to/your/credentials.json') # sh = gc.open_by_key('your_sheet_id') # worksheet = sh.sheet1 # Get data and convert to DataFrame # data = worksheet.get_all_records() # df = pd.DataFrame(data) # Placeholder for demonstration data = [{'col1': 1, 'col2': 2}, {'col1': 3, 'col2': 4}] df = pd.DataFrame(data) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Network Graph Visualization Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of visualizing a simple network graph using NetworkX and Matplotlib. Requires NetworkX and Matplotlib. ```python import networkx as nx import matplotlib.pyplot as plt # Create a graph G = nx.Graph() G.add_edges_from([(1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (4, 6)]) # Define positions for nodes (using a spring layout) pos = nx.spring_layout(G) plt.figure(figsize=(8, 6)) # Draw the graph nx.draw(G, pos, with_labels=True, node_color='skyblue', node_size=1500, edge_color='gray', linewidths=1, font_size=12) plt.title('Network Graph Visualization') plt.show() ``` -------------------------------- ### Plotting with Bokeh Server Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of creating a dynamic plot using Bokeh Server, allowing for real-time updates and interactions. Requires Bokeh. ```python from bokeh.plotting import figure, curdoc from bokeh.models import ColumnDataSource, Slider import numpy as np x = np.linspace(0, 10, 500) y = np.sin(x) source = ColumnDataSource(data=dict(x=x, y=y)) p = figure(height=300, width=600, title='Dynamic Sine Wave Plot', x_axis_label='X-axis', y_axis_label='Y-axis') p.line('x', 'y', source=source, line_width=2) # Add a slider to control amplitude def update_amplitude(attrname, old, new): amplitude = slider.value new_y = amplitude * np.sin(x) source.data = dict(x=x, y=new_y) slider = Slider(start=0.1, end=5.0, value=1.0, step=.1, title="Amplitude") slider.on_change('value', update_amplitude) layout = column(slider, p) curdoc().add_root(layout) curdoc().title = "Dynamic Plot" # To run: save this code as main.py and run 'bokeh serve --show main.py' in your terminal. ``` -------------------------------- ### Team Performance Over Time (Example) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt This is a placeholder for a potential future visualization of team performance over time. It requires time-series data which is not present in the current dataset. ```python # Placeholder for time-series analysis # Requires data with a time component ``` -------------------------------- ### Scatter Plot Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Illustrates how to create a scatter plot. Useful for visualizing relationships between two variables. ```python import matplotlib.pyplot as plt import numpy as np N = 50 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) areas = (30 * np.random.rand(N))**2 plt.scatter(x, y, s=areas, c=colors, alpha=0.5) plt.xlabel("X-axis label") plt.ylabel("Y-axis label") plt.title('Scatter plot with random data') plt.show() ``` -------------------------------- ### Analyze Team Streaks (Example) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt This is a placeholder for analyzing team winning or losing streaks. It would require more detailed match-level data. ```python # Placeholder for streak analysis # Requires match-level data ``` -------------------------------- ### Saving and Loading Models (Pickle) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Demonstrates how to save a trained model to a file and load it back later using pickle. This is crucial for deployment. ```python import pickle with open('model.pkl', 'wb') as f: pickle.dump(model, f) with open('model.pkl', 'rb') as f: loaded_model = pickle.load(f) ``` -------------------------------- ### Seaborn Heatmap with Annotations Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates creating a heatmap with Seaborn, including displaying the data values on each cell. Ensure Seaborn and Matplotlib are installed. ```python import seaborn as sns import matplotlib.pyplot as plt import numpy as np data = np.random.rand(10, 12) sns.heatmap(data, annot=True, cmap='viridis', fmt=".2f") plt.show() ``` -------------------------------- ### Initialize Empty Bohndesliga Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Initializes an empty Bohndesliga table structure. This is a starting point before any data is loaded or processed. ```python def initialize_empty_table(): # Returns an empty list or a list with just headers return [] empty_table = initialize_empty_table() ``` -------------------------------- ### Get Row as List Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves all values from a specified row as a Python list. ```python row_as_list = table.get_row_as_list(row_index=0) ``` -------------------------------- ### Get Column as List Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves all values from a specified column as a Python list. ```python column_as_list = table.get_column_as_list("column_name") ``` -------------------------------- ### Get Column Index Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Returns the index (position) of a column given its name. ```python col_index = table.get_column_index("column_name") ``` -------------------------------- ### Example Usage of Bohndesliga Functions Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Demonstrates how to use the previously defined functions to load data, calculate standings, and display the table. Ensure you have a CSV file with the correct columns. ```python file_path = 'path/to/your/bohndesliga_matches.csv' df = load_and_process_data(file_path) standings = calculate_standings(df) display_table(standings) ``` -------------------------------- ### Get Min Value from Column Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the minimum value from a specified column. ```python min_val = table.get_min_value("column_name") ``` -------------------------------- ### Initialize and Populate Bohndesliga Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt This snippet demonstrates how to initialize and populate the Bohndesliga table. It involves setting up the table structure and then filling it with data, likely from a data source. ```python def init_table(): # Initialize the table table = [["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] # Populate with data # ... (data population logic here) ... return table bohndesliga_table = init_table() ``` -------------------------------- ### Create a Basic Table with Plottable.js Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Demonstrates how to create a simple DataFrame and render it as a table using Plottable.js. Ensure Matplotlib is imported for saving the figure. ```python d = pd.DataFrame(np.random.random((5, 5)), columns=["A", "B", "C", "D", "E"]).round(2) fig, ax = plt.subplots(figsize=(6, 3)) tab = Table(d) plt.show() fig.savefig("images/basic_table.png") ``` -------------------------------- ### Get Max Value from Column Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the maximum value from a specified column. ```python max_val = table.get_max_value("column_name") ``` -------------------------------- ### Get Table Dimensions Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Returns the number of rows and columns in the Bohndesliga table. ```python num_rows, num_cols = table.get_dimensions() ``` -------------------------------- ### plottable.cell.Column.get_yrange Source: https://plottable.readthedocs.io/en/latest/plottable.html Gets the yrange of the Column. Returns a tuple of minimum and maximum y values. ```APIDOC ## get_yrange() -> Tuple[float, float] ### Description Gets the yrange of the Column. ### Returns - Tuple[float, float]: A tuple containing the minimum and maximum y values. ``` -------------------------------- ### plottable.cell.Row.get_yrange Source: https://plottable.readthedocs.io/en/latest/plottable.html Gets the yrange of the Row. Returns a tuple of minimum and maximum y values. ```APIDOC ## get_yrange() -> Tuple[float, float] ### Description Gets the yrange of the Row. ### Returns - Tuple[float, float]: A tuple containing the minimum and maximum y values. ``` -------------------------------- ### Create a Plot Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Creates a simple plot from the 'TotalGoals' column. Requires matplotlib to be installed. ```python import matplotlib.pyplot as plt plt.figure(figsize=(10, 6)) plt.plot(df['TotalGoals'].values) plt.title('Total Goals Over Time') plt.xlabel('Match Index') plt.ylabel('Total Goals') plt.grid(True) plt.show() ``` -------------------------------- ### Plotting with Datashader Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of using Datashader for rendering large datasets quickly, often used with HoloViews. Requires Datashader, HoloViews, and hvPlot. ```python import datashader as ds import datashader.transfer_functions as tf from datashader.colors import Hot import holoviews as hv import numpy as np import pandas as pd hv.extension('bokeh') # Generate a large dataset num_points = 1_000_000 x = np.random.rand(num_points) * 100 y = np.random.rand(num_points) * 100 df = pd.DataFrame({'x': x, 'y': y}) # Create a HoloViews Points element points = hv.Points(df, kdims=['x', 'y']) # Apply Datashader rendering cv = ds.Canvas() agg = cv.points(df, 'x', 'y') img = tf.shade(agg, cmap=Hot, how='log') # Convert Datashader image to HoloViews object for display datashader_plot = hv.Image(img) # To display in notebook or save: # hv.save(datashader_plot, 'datashader_plot.html') datashader_plot ``` -------------------------------- ### Get Team Points Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the current points for a specific team from the Bohndesliga table. ```python def get_team_points(table, team_name): index = get_team_index(table, team_name) if index != -1: return table[index][9] # Assuming points are in the 10th column (index 9) return 0 # Return 0 if team not found # Example usage: # team_a_points = get_team_points(bh_table, "Team A") ``` -------------------------------- ### Get Column Name by Index Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Returns the name of a column given its index (position). ```python col_name = table.get_column_name_by_index(0) ``` -------------------------------- ### Basic Data Handling Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Demonstrates fundamental data operations. Ensure necessary libraries are imported. ```python import pandas as pd import numpy as np # Sample data creation data = { 'Team': ['Team A', 'Team B', 'Team C', 'Team D', 'Team E'], 'Played': [34, 34, 34, 34, 34], 'Won': [20, 18, 15, 12, 10], 'Drawn': [8, 10, 12, 14, 16], 'Lost': [6, 6, 7, 8, 8], 'GoalsFor': [70, 65, 55, 45, 40], 'GoalsAgainst': [30, 35, 40, 45, 50], 'GoalDifference': [40, 30, 15, 0, -10], 'Points': [68, 64, 57, 50, 46] } df = pd.DataFrame(data) # Calculate Goal Difference if not present if 'GoalDifference' not in df.columns: df['GoalDifference'] = df['GoalsFor'] - df['GoalsAgainst'] # Calculate Points if not present if 'Points' not in df.columns: df['Points'] = df['Won'] * 3 + df['Drawn'] * 1 print(df.head()) ``` -------------------------------- ### Heatmap with Data from Database Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Shows how to query data from a database, load it into a Pandas DataFrame, and then visualize it as a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import sqlite3 conn = sqlite3.connect('mydatabase.db') df = pd.read_sql_query("SELECT * from mytable", conn) conn.close() sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### plottable.cell.Column.get_xrange Source: https://plottable.readthedocs.io/en/latest/plottable.html Gets the xrange of the Column. Returns a tuple of minimum and maximum x values. ```APIDOC ## get_xrange() -> Tuple[float, float] ### Description Gets the xrange of the Column. ### Returns - Tuple[float, float]: A tuple containing the minimum and maximum x values. ``` -------------------------------- ### plottable.cell.Row.get_xrange Source: https://plottable.readthedocs.io/en/latest/plottable.html Gets the xrange of the Row. Returns a tuple of minimum and maximum x values. ```APIDOC ## get_xrange() -> Tuple[float, float] ### Description Gets the xrange of the Row. ### Returns - Tuple[float, float]: A tuple containing the minimum and maximum x values. ``` -------------------------------- ### Heatmap with Data from Clipboard Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Demonstrates loading data directly from the system clipboard into a Pandas DataFrame and then creating a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Copy data to clipboard first df = pd.read_clipboard() sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Heatmap with Data from SQL Database (Specific Query) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates fetching specific columns and rows from a SQL database using a custom query to create a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import sqlalchemy engine = sqlalchemy.create_engine('sqlite:///mydatabase.db') query = "SELECT columnA, columnB FROM mytable WHERE condition = 'value'" df = pd.read_sql(query, engine) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Basic Data Loading and Display Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt This snippet shows how to load and display data. Ensure data is in a compatible format. ```python import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(10, 5)) df.columns = [f"col{i}" for i in range(5)] df.head() ``` -------------------------------- ### Display a Plot Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt This code generates a basic plot and displays it. Ensure you have the necessary libraries installed. ```python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) plt.figure(figsize=(6, 3)) plt.plot(x, y) plt.title('Sine Wave') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.grid(True) plt.show() ``` -------------------------------- ### Heatmap with Data from API Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates fetching data from an API, processing it, and then displaying it as a heatmap. Requires libraries like `requests`. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import requests # Example API endpoint (replace with a real one) api_url = "https://api.example.com/data" response = requests.get(api_url) data = response.json() df = pd.DataFrame(data) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Get Team Goal Difference Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the goal difference for a specific team from the Bohndesliga table. ```python def get_team_goal_difference(table, team_name): index = get_team_index(table, team_name) if index != -1: return table[index][8] # Assuming goal difference is in the 9th column (index 8) return 0 # Return 0 if team not found # Example usage: # team_a_gd = get_team_goal_difference(bh_table, "Team A") ``` -------------------------------- ### Get Distinct Rows Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Returns a new table containing only the distinct rows from the original table. ```python distinct_rows_table = table.get_distinct_rows() ``` -------------------------------- ### Bar Chart with HoloViews Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to create a bar chart using HoloViews, mapping categorical and numerical data. Requires HoloViews, hvPlot, and Pandas. ```python import holoviews as hv import pandas as pd hv.extension('bokeh') data = {'categories': ['A', 'B', 'C', 'D', 'E'], 'values': [23, 45, 56, 12, 39]} df = pd.DataFrame(data) bars = hv.Bars(df, 'categories', 'values').opts( title='HoloViews Bar Chart', xlabel='Category', ylabel='Value', tools=['hover'] ) # To display in notebook or save: # hv.save(bars, 'holoviews_bar_chart.html') bars ``` -------------------------------- ### Get Unique Column Names Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves a list of all unique column names present in the table. ```python unique_names = table.get_unique_column_names() ``` -------------------------------- ### Get Column Data Type Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the data type of a specified column in the Bohndesliga table. ```python data_type = table.get_column_type("column_name") ``` -------------------------------- ### Interactive Bar Chart with Bokeh Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to create an interactive bar chart using Bokeh, suitable for web-based visualizations. Ensure Bokeh is installed. ```python from bokeh.plotting import figure, show from bokeh.models import ColumnDataSource import pandas as pd # output_notebook() # Uncomment to display in Jupyter Notebook data = {'categories': ['A', 'B', 'C', 'D', 'E'], 'values': [23, 45, 56, 12, 39]} df = pd.DataFrame(data) source = ColumnDataSource(df) p = figure(x_range=df['categories'], height=350, title="Interactive Bokeh Bar Chart", x_axis_label='Category', y_axis_label='Value') p.vbar(x='categories', top='values', width=0.9, source=source, color="#718dbf") # To save to HTML file: # from bokeh.io import output_file # output_file("bar_chart.html") p.xgrid.grid_line_color = None p.y_range.start = 0 show(p) ``` -------------------------------- ### Get Column Data from Bohndesliga Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves all data from a specific column in the Bohndesliga table. ```python column_data = table.get_column("column_name") ``` -------------------------------- ### Histogram with Altair Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a histogram to visualize data distribution using Altair. Requires Altair and Pandas. ```python import altair as alt import pandas as pd import numpy as np data = np.random.randn(1000) df = pd.DataFrame({'value': data}) chart = alt.Chart(df).mark_bar().encode( alt.X('value', bin=True, title='Value'), alt.Y('count()', title='Frequency'), tooltip=[alt.Tooltip('value', bin=True, title='Value Range'), 'count()'] ).properties( title='Altair Histogram' ) # To save the chart: # chart.save('altair_histogram.html') chart.show() ``` -------------------------------- ### Line Plot with Multiple Lines Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of plotting multiple lines on the same axes. Useful for comparing trends. ```python import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) y1 = np.sin(x) y2 = np.cos(x) plt.plot(x, y1, label='sin(x)') plt.plot(x, y2, label='cos(x)') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.title('Multiple Lines Plot') plt.legend() plt.show() ``` -------------------------------- ### Instantiate Table with ColumnDefinition Source: https://plottable.readthedocs.io/en/latest/notebooks/column_definition.html Provide a list of ColumnDefinition objects to the Table constructor to customize specific columns. ```python from plottable import ColumnDefinition Table(df, column_definitions: List[ColumnDefinition]=None) ``` -------------------------------- ### Creating a Simple Plot Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Demonstrates the creation of a basic plot using a DataFrame. Requires pandas and a plotting library. ```python import matplotlib.pyplot as plt plt.plot(df['col0'], df['col1']) plt.xlabel('Column 0') plt.ylabel('Column 1') plt.title('Column 0 vs Column 1') plt.show() ``` -------------------------------- ### Heatmap with Data from API (Clipboard) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates fetching data from an API that returns data suitable for clipboard, then loading it into a DataFrame and plotting a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import requests import io api_url = "https://api.example.com/data_for_clipboard" response = requests.get(api_url) # Assuming the response text is formatted like tab-separated values data_for_clipboard = io.StringIO(response.text) df = pd.read_clipboard(sep='\t') # Adjust sep if needed sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Retrieve Bohndesliga Table Data Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Fetches data for the Bohndesliga table. Ensure necessary libraries are installed. ```python import pandas as pd url = "https://raw.githubusercontent.com/plotly/datasets/master/Bohndesliga_table.csv" df = pd.read_csv(url) print(df.head()) ``` -------------------------------- ### Histogram with HoloViews Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Demonstrates creating a histogram to visualize data distribution using HoloViews. Requires HoloViews, hvPlot, and Pandas. ```python import holoviews as hv import numpy as np import pandas as pd hv.extension('bokeh') data = np.random.randn(1000) df = pd.DataFrame({'value': data}) hist = hv.Histogram(df, 'value').opts( title='HoloViews Histogram', xlabel='Value', ylabel='Frequency', tools=['hover'] ) # To display in notebook or save: # hv.save(hist, 'holoviews_histogram.html') hist ``` -------------------------------- ### Get Table as List of Dictionaries Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Converts the entire table into a list of dictionaries, where each dictionary represents a row. ```python list_of_dicts = table.get_table_as_list_of_dicts() ``` -------------------------------- ### Initialize Bohndesliga Table with Headers Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt This snippet initializes the Bohndesliga table with predefined headers. This sets up the column structure for the table before data is added. ```python def init_table_with_headers(): headers = ["Rank", "Team", "Played", "Won", "Drawn", "Lost", "Goals For", "Goals Against", "Goal Difference", "Points"] table = [headers] # Add empty rows for teams if needed # ... return table bh_table = init_table_with_headers() ``` -------------------------------- ### Basic Plotting with HoloViews Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Example of creating a simple interactive line plot using HoloViews, a high-level library for building visualizations. Requires HoloViews, hvPlot, and Pandas. ```python import holoviews as hv import numpy as np import pandas as pd hv.extension('bokeh') # Use 'bokeh' or 'matplotlib' backend x = np.linspace(0, 10, 100) y = np.sin(x) df = pd.DataFrame({'x': x, 'y': y}) curve = hv.Curve(df, 'x', 'y').opts(title='Simple HoloViews Line Plot', xlabel='X-axis', ylabel='Y-axis') # To display in notebook or save: # hv.save(curve, 'holoviews_line_plot.html') curve ``` -------------------------------- ### Get Row as Dictionary Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves all values from a specified row as a dictionary, mapping column name to value. ```python row_as_dict = table.get_row_as_dict(row_index=0) ``` -------------------------------- ### Get Column as Dictionary Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves all values from a specified column as a dictionary, mapping row index to value. ```python column_as_dict = table.get_column_as_dict("column_name") ``` -------------------------------- ### Heatmap with Data from Protocol Buffers Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates loading data serialized with Protocol Buffers into a Pandas DataFrame and then creating a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import your_proto_module # Assuming you have compiled your .proto file # Assume 'data.pb' contains serialized protobuf messages with open('data.pb', 'rb') as f: serialized_data = f.read() # Deserialize the data (example assumes a list of messages) # You'll need to adapt this based on your protobuf structure # For example, if it's a repeated field of MyMessage: # messages = your_proto_module.MyMessageList() # messages.ParseFromString(serialized_data) # data_list = [msg.field1 for msg in messages.messages] # Placeholder for deserialized data data_list = [[1, 2], [3, 4]] # Replace with actual deserialized data df = pd.DataFrame(data_list) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Heatmap with Data from API (SQL Query) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Illustrates fetching data from a SQL database via an API endpoint that executes a query, then plotting a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import requests api_url = "https://api.example.com/query_data" params = {'query': "SELECT columnA, columnB FROM mytable WHERE condition = 'value'"} response = requests.get(api_url, params=params) df = pd.DataFrame(response.json()) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Get Row Count by Group Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Counts the number of rows for each unique value in a specified grouping column. ```python group_counts = table.get_row_count_by_group("grouping_column") ``` -------------------------------- ### Heatmap with Data from Text File (Space-Separated) Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Demonstrates loading data from a space-separated text file into a Pandas DataFrame and then creating a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Assume 'data.txt' exists with space-separated values df = pd.read_csv('data.txt', sep='\s+', index_col=0) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Get Column Values by Condition Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves values from a specified column for rows that satisfy a given condition. ```python values = table.get_column_values_by_condition("column_to_get", "condition_column", "=", "value") ``` -------------------------------- ### Get Row Count by Condition Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Counts the number of rows that satisfy a given condition on a specific column. ```python count = table.count_rows_by_condition("column_name", ">", 10) ``` -------------------------------- ### Heatmap with Data from YAML Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Demonstrates loading data from a YAML file into a Pandas DataFrame and then creating a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import yaml # Assume 'data.yaml' exists with open('data.yaml', 'r') as f: data = yaml.safe_load(f) df = pd.DataFrame(data) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Get Table Schema Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Returns the schema of the Bohndesliga table, including column names and their data types. ```python schema = table.get_schema() ``` -------------------------------- ### Get Value from Cell Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves the value of a specific cell identified by its row index and column name. ```python cell_value = table.get_cell_value(row_index=0, column_name="column_name") ``` -------------------------------- ### Create a DataFrame and Render a Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Prepare a pandas DataFrame with random data and then render it as a table using Plottable. This is useful for displaying tabular data visually. ```python d = pd.DataFrame(np.random.random((5, 5)), columns=["A", "B", "C", "D", "E"]).round(2) fig, ax = plt.subplots(figsize=(6, 3)) tab = Table(d, row_dividers=False, odd_row_color="#f0f0f0", even_row_color="#e0f6ff") tab.render() ``` -------------------------------- ### Get Column Names from Bohndesliga Table Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Retrieves a list of all column names currently in the Bohndesliga table. ```python column_names = table.get_column_names() ``` -------------------------------- ### Heatmap with Data from Fixed-Width File Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/heatmap.ipynb.txt Shows how to load data from a fixed-width formatted file into a Pandas DataFrame and then visualize it as a heatmap. ```python import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Assume 'data.fwf' exists with fixed-width columns # Define column widths and names as needed # colspecs = [(0, 5), (5, 10)] # names = ['col1', 'col2'] # df = pd.read_fwf('data.fwf', colspecs=colspecs, names=names) sns.heatmap(df, cmap='Blues') plt.show() ``` -------------------------------- ### Visualize Win Percentage by Team Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/bohndesliga_table.ipynb.txt Creates a bar chart showing the win percentage for each team. This provides a clear comparison of team success rates. ```python plt.figure(figsize=(10, 6)) sns.barplot(data=df, x="Team", y="Win Percentage") plt.xticks(rotation=90) plt.title("Win Percentage by Team") plt.show() ``` -------------------------------- ### Data Filtering Example Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/basic_example.ipynb.txt Shows how to filter a DataFrame based on specific conditions. Useful for selecting subsets of data. ```python filtered_df = df[df['col0'] > 0.5] ``` -------------------------------- ### Bar Chart with Altair Source: https://plottable.readthedocs.io/en/latest/_sources/example_notebooks/plot_example.ipynb.txt Shows how to create a bar chart using Altair, suitable for comparing categorical data. Requires Altair and Pandas. ```python import altair as alt import pandas as pd data = {'categories': ['A', 'B', 'C', 'D', 'E'], 'values': [23, 45, 56, 12, 39]} df = pd.DataFrame(data) chart = alt.Chart(df).mark_bar().encode( x=alt.X('categories', title='Category'), y=alt.Y('values', title='Value'), tooltip=['categories', 'values'] ).properties( title='Altair Bar Chart' ) # To save the chart: # chart.save('altair_bar_chart.html') chart.show() ```