A DataFrame in Snowpark is like a table in a database. It holds data in rows and columns and lets you work with that data using simple commands.
Click to reveal answer
beginner
How do you create a DataFrame from a Snowflake table using Snowpark?
You use the session object and call table("table_name"). For example, df = session.table("my_table") creates a DataFrame from the table named 'my_table'.
Click to reveal answer
beginner
What does the filter() method do in a Snowpark DataFrame?
The filter() method selects rows that meet a condition. It’s like picking only the data you want based on rules you set.
Click to reveal answer
intermediate
Explain the difference between select() and filter() in Snowpark DataFrames.
select() chooses which columns to keep, while filter() chooses which rows to keep based on conditions.
Click to reveal answer
beginner
How does Snowpark DataFrame help with processing data in Snowflake?
Snowpark DataFrame lets you write code that runs inside Snowflake, so data stays safe and processing is fast without moving data outside.
Click to reveal answer
Which method creates a DataFrame from a Snowflake table in Snowpark?
Asession.createDataFrame()
Bsession.loadTable()
Csession.table("table_name")
Dsession.newDataFrame()
✗ Incorrect
The correct method to create a DataFrame from an existing table is session.table("table_name").
What does the filter() method do in a Snowpark DataFrame?
ASelects rows based on a condition
BSelects columns
CJoins two DataFrames
DSorts the DataFrame
✗ Incorrect
filter() selects rows that meet a condition.
Which method would you use to choose specific columns in a Snowpark DataFrame?
Afilter()
Bselect()
CgroupBy()
Djoin()
✗ Incorrect
select() is used to choose specific columns.
Why is processing data with Snowpark DataFrame efficient?
ABecause it runs code inside Snowflake without moving data
BBecause it uses external servers
CBecause it moves data to your local machine
DBecause it exports data to CSV first
✗ Incorrect
Snowpark runs code inside Snowflake, keeping data secure and processing fast.
What is the main structure used to hold data in Snowpark?
AArray
BDictionary
CList
DDataFrame
✗ Incorrect
DataFrame is the main structure to hold and work with data in Snowpark.
Describe how you would create and filter a DataFrame in Snowpark.
Think about starting from a table and then picking rows you want.
You got /3 concepts.
Explain the difference between selecting columns and filtering rows in a Snowpark DataFrame.
One picks what data fields to keep, the other picks which records to keep.
You got /3 concepts.
Practice
(1/5)
1. What does the filter() method do in Snowpark's DataFrame API?
easy
A. It adds new columns to the DataFrame.
B. It changes the column names of the DataFrame.
C. It selects rows that meet a specified condition.
D. It sorts the DataFrame by a column.
Solution
Step 1: Understand the purpose of filter()
The filter() method is used to keep only rows that satisfy a condition.
Step 2: Compare with other methods
Changing column names is done by withColumnRenamed(), adding columns by withColumn(), and sorting by orderBy().
Final Answer:
It selects rows that meet a specified condition. -> Option C
Quick Check:
filter() = select rows [OK]
Hint: Filter keeps rows matching condition, like a sieve [OK]
Common Mistakes:
Confusing filter() with select()
Thinking filter() changes columns
Using filter() to sort data
2. Which of the following is the correct way to select columns name and age from a DataFrame df in Snowpark?
easy
A. df.select('name', 'age')
B. df.filter('name', 'age')
C. df.orderBy('name', 'age')
D. df.withColumn('name', 'age')
Solution
Step 1: Identify method to pick columns
The select() method is used to choose specific columns from a DataFrame.
Step 2: Check other methods
filter() is for rows, orderBy() sorts rows, and withColumn() adds or modifies columns.
Final Answer:
df.select('name', 'age') -> Option A
Quick Check:
Select columns = select() [OK]
Hint: Use select() to pick columns, not filter() or orderBy() [OK]
D. Using single equals (=) instead of double equals (==) in filter condition
Solution
Step 1: Check filter condition syntax
The filter condition uses = which is assignment, not comparison. It should be ==.
Step 2: Verify other parts
Schema is correct, parentheses are fine, and show() is valid to display results.
Final Answer:
Using single equals (=) instead of double equals (==) in filter condition -> Option D
Quick Check:
Use == for comparison in filter [OK]
Hint: Use == for conditions, not = [OK]
Common Mistakes:
Using = instead of == in conditions
Thinking show() is invalid
Confusing schema errors with syntax errors
5. You want to create a new column age_group in a Snowpark DataFrame df that labels ages below 18 as 'minor' and 18 or above as 'adult'. Which code snippet correctly achieves this?
hard
A. df.select('age_group', F.when(df['age'] < 18, 'minor').otherwise('adult'))
B. df.withColumn('age_group', F.when(df['age'] < 18, 'minor').otherwise('adult'))
C. df.filter(df['age_group'] == 'minor')
D. df.orderBy('age_group')
Solution
Step 1: Understand how to add a conditional column
The withColumn() method adds or replaces a column. Using F.when().otherwise() sets values conditionally.
Step 2: Check other options
select() chooses columns but does not add new ones, filter() filters rows, and orderBy() sorts rows.
Final Answer:
df.withColumn('age_group', F.when(df['age'] < 18, 'minor').otherwise('adult')) -> Option B
Quick Check:
Add conditional column with withColumn + when [OK]
Hint: Use withColumn and when() to add conditional columns [OK]
Common Mistakes:
Using select() to add columns
Filtering instead of adding columns
Ordering instead of creating new columns
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.