Views

Pixeltable views provide dynamic and customizable ways to interact with your data. They act as lenses through which you can filter, transform, and even augment your original dataset without altering the underlying data itself.

What are Views?

A view is essentially a saved query on a Pixeltable. It allows you to create a virtual table that presents a subset or transformation of the original data (table), tailored to your specific needs. Views are incredibly useful for:

  • Data Exploration: Isolate specific subsets of your data for analysis, filtering by criteria or applying transformations.
  • Experimentation: Easily experiment with different transformations or model parameters without modifying your original data.
  • Collaboration: Share curated views of your data with teammates, focusing their attention on specific insights.

Creating Views

You create a view by specifying a base table and defining either a filter or an iterator (or both). The create_view function is your main tool:

filtered_view = pxt.create_view('my_view', base_table, filter=base_table.col1 > 10)

In this example, filtered_view is a new view showing only rows where the value in col1 is greater than 10.

Types of Views

  • Filtered Views: Apply conditions to display only a subset of rows from the base table.
  • Transformed Views: Use computed columns within the view to create new features, apply functions, or even run models on the original data.
  • Component Views (with Iterators): These specialized views break down complex data types (e.g., videos) into their constituent components (e.g., frames). Pixeltable provides iterators like FrameIterator for this purpose or DocumentSplitter for RAG: Experimenting with Chunking.
  • Snapshot Views: Capture a static view of a table at a specific point in time, useful for reproducibility and analysis.

Learn more through our API Reference

Example: Exploring Video Data

from pixeltable.iterators import FrameIterator

videos_table = pxt.get_table('my_videos')  
frames_view = pxt.create_view('frames', videos_table, iterator=FrameIterator.create(videos_table.video, fps=1))

Here, frames_view lets you explore frames from all videos in videos_table. You could then define computed columns within this view for tasks like object detection or image classification.

Working with Views

Views behave like regular tables within Pixeltable. You can:

  • Query Them: Apply filters, select specific columns, and perform calculations.
  • Update Them: (If not a snapshot view) Modify the underlying data, with changes automatically reflected in the view.
  • Chain Them: Create views on top of existing views for increasingly specific or complex transformations.

Key Points about Views

  • Efficiency: Views don't duplicate data; they operate on the original table data on-demand. This saves storage space and makes complex transformations faster.
  • Flexibility: Experiment with different data preparation, feature engineering, and modeling techniques without risking your original data.
  • Lineage Tracking: Even though views are virtual, their lineage is tracked back to the original base table, ensuring complete transparency.