0
0
Snowflakecloud~30 mins

Snowpark for Python basics in Snowflake - Mini Project: Build & Apply

Choose your learning style9 modes available
Snowpark for Python basics
📖 Scenario: You are working with Snowflake's Snowpark for Python to process data inside the cloud database. You want to create a simple Snowpark session, load some sample data into a DataFrame, and perform a basic transformation.
🎯 Goal: Build a Snowpark Python script that creates a session, loads a small dataset into a DataFrame, filters the data, and shows the result.
📋 What You'll Learn
Create a Snowpark session with exact parameters
Create a DataFrame from a list of tuples with specific data
Filter the DataFrame using a condition on a column
Show the filtered DataFrame content
💡 Why This Matters
🌍 Real World
Snowpark for Python lets you run Python code close to your data inside Snowflake, reducing data movement and improving performance.
💼 Career
Data engineers and analysts use Snowpark to build scalable data pipelines and transformations directly in Snowflake using Python.
Progress0 / 4 steps
1
Create a Snowpark session
Write code to create a Snowpark session called session using Session.builder.configs() with the exact dictionary {'account': 'xy12345', 'user': 'user1', 'password': 'pass123', 'role': 'SYSADMIN', 'warehouse': 'COMPUTE_WH', 'database': 'TEST_DB', 'schema': 'PUBLIC'} and then call .create().
Snowflake
Need a hint?

Use Session.builder.configs() with the exact dictionary and then call .create() to make the session.

2
Create a DataFrame with sample data
Create a variable called data that is a list of tuples with these exact entries: (1, 'Apple'), (2, 'Banana'), (3, 'Cherry'). Then create a Snowpark DataFrame called df from data using session.create_dataframe(data, schema=['id', 'fruit']).
Snowflake
Need a hint?

Make a list called data with the exact tuples. Then use session.create_dataframe() with data and the schema list ['id', 'fruit'].

3
Filter the DataFrame for fruits with id greater than 1
Create a new DataFrame called filtered_df by filtering df where the id column is greater than 1 using df.filter(df['id'] > 1).
Snowflake
Need a hint?

Use df.filter(df['id'] > 1) to create filtered_df.

4
Show the filtered DataFrame content
Call filtered_df.show() to display the filtered data.
Snowflake
Need a hint?

Call filtered_df.show() to display the filtered rows.