Skip to main content

Overview

Pylar allows you to work with Local Dataframes—data that’s already loaded in your Pylar session. This enables you to query and join multiple dataframes using SQL, creating unified views without needing to connect to external databases.

What Are Local Dataframes?

Local Dataframes are:
  • Data tables loaded into your Pylar session
  • Accessible through the SQL IDE
  • Queryable using standard SQL syntax
  • Joinable across multiple dataframes
Think of dataframes as temporary tables that exist in your current Pylar session. They’re perfect for combining data from multiple sources or working with intermediate results.

Setting Up Dataframe Queries

To query local dataframes:
  1. Select Dataframe Source: In the SQL IDE, set the datasource dropdown to “Local Dataframes”
  2. Reference Dataframe Names: Use the dataframe name as the table name in your SQL query
  3. Write Standard SQL: Use familiar SQL syntax to query and join your dataframes
Dataframe names are case-sensitive and must match exactly. Make sure you know the exact names of your loaded dataframes before querying.

Basic Dataframe Queries

Selecting from a Single Dataframe

Query a specific subset of data from a dataframe:
This query:
  • References table0 as a dataframe in your session
  • Filters rows where event_type equals 'login'
  • Returns all columns (*) from matching rows

Selecting Specific Columns

Filtering and Sorting

Joining Multiple Dataframes

One of the most powerful features is joining data from multiple dataframes to create unified views.

Basic Join Syntax

Example: Joining on Common ID

Join two dataframes on a common identifier:
This query:
  • Joins table1 and table2 dataframes
  • Matches rows where event_id values are equal
  • Returns selected columns from both dataframes
  • Uses table aliases (t1, t2) for clarity
Always use table aliases when joining dataframes. It makes your queries more readable and helps avoid column name conflicts.

Advanced Join Patterns

Multiple Dataframe Joins

Join three or more dataframes:

Left Join for Optional Data

Include all rows from the first dataframe, with optional data from the second:

Full Outer Join

Include all rows from both dataframes:

Real-World Examples

Example 1: Customer Event Analysis

Combine customer events with user profiles:

Example 2: Marketing Attribution

Join campaign data with conversion events:

Example 3: Product Performance Analysis

Combine product catalog with sales and reviews:

Join Types for Dataframes

INNER JOIN

Returns only rows that have matches in both dataframes.
Use When: You only want data that exists in both dataframes.

LEFT JOIN

Returns all rows from the left dataframe, matched rows from the right.
Use When: You want all data from the primary dataframe, with optional data from the secondary.

RIGHT JOIN

Returns all rows from the right dataframe, matched rows from the left.
Use When: You want all data from the secondary dataframe, with optional data from the primary.

FULL OUTER JOIN

Returns all rows from both dataframes, with NULLs for missing matches.
Use When: You want to combine data from both dataframes regardless of matches.

Handling Data Type Mismatches

When joining dataframes, ensure join keys are compatible:

String vs Numeric IDs

Handling NULL Values

Case-Insensitive Matching

Best Practices

1. Use Descriptive Aliases

2. Select Specific Columns

3. Filter Early

4. Handle NULLs Explicitly

5. Verify Dataframe Existence

Before querying, ensure your dataframes are loaded and named correctly. Test with a simple query first:

Common Issues and Solutions

Issue: “Table not found” Error

Cause: Dataframe doesn’t exist or name is incorrect. Solution:
  • Verify dataframe is loaded in your session
  • Check dataframe name matches exactly (case-sensitive)
  • Ensure datasource is set to “Local Dataframes”

Issue: Join Returns No Results

Cause: Join keys don’t match or have incompatible types. Solution:
  • Verify join keys exist in both dataframes
  • Check data types match (use CAST if needed)
  • Test join keys individually:

Issue: Column Name Conflicts

Cause: Both dataframes have columns with the same name. Solution:
  • Use table aliases and qualify column names
  • Use AS to rename columns in SELECT
  • Example:

Issue: Performance Issues

Cause: Large dataframes or complex joins. Solution:
  • Filter dataframes before joining
  • Use LIMIT to test with smaller datasets
  • Consider aggregating dataframes first

Next Steps

Now that you understand cross-database joins:

Create Unified Views

Learn how to combine dataframe queries with database queries