In my previous two blogs, we explored how I built a smoothie ordering application using Snowflake, Python and Streamlit, and how I introduced an external API to display nutritional information.
Towards the end of the workshop, I encountered a problem that initially seemed quite small: the fruit names stored in Snowflake did not always match the names expected by the external API.
To solve this problem, we needed to prepare our data differently and introduce another Python library called Pandas. In this blog, I want to explore what Pandas is, how it differs from Snowpark and how we used it to help two different systems work together.
1. Understanding the problem
Imagine a customer selects Apples from our smoothie application. Our Python code takes that selection and uses it to build an API request.
https://my.smoothiefroot.com/api/fruit/Apples
However, the API expects Apple rather than Apples. As humans, we understand that these names refer to the same fruit, but different systems may expect information in a particular format.
| Name in Snowflake | Name expected by the API |
|---|---|
| Apples | Apple |
| Blueberries | Blueberry |
| Jack Fruit | Jackfruit |
| Strawberries | Strawberry |

One option would have been to change the original fruit names in Snowflake. However, we wanted to retain the names displayed to the customer while also having the correct values for our API requests.
2. Introducing the SEARCH_ON column
To solve this problem, we introduced another column in our FRUIT_OPTIONS table called SEARCH_ON. We prepared the mapping using SQL in Snowflake, rather than through Pandas.
The following SQL examples illustrate how we can prepare this mapping, revisiting concepts from the earlier blogs.
Adding a new column
As our table already existed, we could use ALTER TABLE to add another column.
ALTER TABLE SMOOTHIES.PUBLIC.FRUIT_OPTIONS
ADD COLUMN SEARCH_ON VARCHAR(100);
Our table would initially look something like this:
| FRUIT_NAME | SEARCH_ON |
|---|---|
| Apples | NULL |
| Blueberries | NULL |
| Jack Fruit | NULL |
| Mango | NULL |
The new column exists, but we haven't populated it with any values yet.
Populating the new column
Rather than manually entering every fruit name again, we can copy the existing names into our new column.
UPDATE SMOOTHIES.PUBLIC.FRUIT_OPTIONS
SET SEARCH_ON = FRUIT_NAME
WHERE SEARCH_ON IS NULL;
| FRUIT_NAME | SEARCH_ON |
|---|---|
| Apples | Apples |
| Blueberries | Blueberries |
| Jack Fruit | Jack Fruit |
| Mango | Mango |
Correcting the names that don't match
We can then update the individual values that need changing. For example:
UPDATE SMOOTHIES.PUBLIC.FRUIT_OPTIONS
SET SEARCH_ON = 'Apple'
WHERE FRUIT_NAME = 'Apples';
UPDATE SMOOTHIES.PUBLIC.FRUIT_OPTIONS
SET SEARCH_ON = 'Blueberry'
WHERE FRUIT_NAME = 'Blueberries';
We repeat the process for other mismatches, such as Jack Fruit and Strawberries. The completed mapping contains information like this:
| FRUIT_NAME | SEARCH_ON |
|---|---|
| Apples | Apple |
| Blueberries | Blueberry |
| Jack Fruit | Jackfruit |
| Strawberries | Strawberry |
| Mango | Mango |
FRUIT_NAME is what the customer sees. SEARCH_ON is what our application uses when communicating with the API.

This is an example of data mapping: establishing a relationship between values used by different systems. We have prepared the mapping in Snowflake, but we still need to work out how Python can find the correct search value whenever a customer selects a fruit.
3. Retrieving both columns using Snowpark
In Blog 3, we explored how Snowpark allows Python to communicate with Snowflake. Previously, we were mainly interested in retrieving fruit names to populate our multiselect. Now, we also need the SEARCH_ON column.
my_dataframe = session.table(
"smoothies.public.fruit_options"
).select(
col('FRUIT_NAME'),
col('SEARCH_ON')
)
If we were writing this directly in SQL, it would be similar to:
SELECT FRUIT_NAME, SEARCH_ON
FROM SMOOTHIES.PUBLIC.FRUIT_OPTIONS;
Both examples describe the information we want to retrieve. The difference is that in our Python application, we are using Snowpark.
The variable my_dataframe holds a Snowpark DataFrame representing the two selected columns. At this point, we have described the data we want to work with.
4. What is Pandas?
Pandas is a Python library that allows us to work with, explore and manipulate data. For example, we can select columns, find rows that match a condition, sort information and perform calculations.
One of the main structures used in Pandas is called a DataFrame. A DataFrame allows us to work with information organised into rows and columns, similar to a spreadsheet or a database table.
To use Pandas, we imported the library:
import pandas as pd
Just as we used st as a shorter name for Streamlit, pd is a commonly used shorter name for Pandas.
However, this introduced a question for me. If Snowpark already provides a DataFrame, why are we introducing another type of DataFrame?
5. Snowpark DataFrame vs Pandas DataFrame
Although both allow us to work with structured data, they do not work in exactly the same way.
A Snowpark DataFrame allows us to describe operations that can be performed within Snowflake. A standard Pandas DataFrame allows us to work with retrieved data directly within our Python environment.
| Snowpark DataFrame | Pandas DataFrame |
|---|---|
| Works with data in Snowflake | Works with data retrieved into Python |
| Processing generally takes place in Snowflake | Processing takes place in the Python environment |
| Useful for processing large datasets within Snowflake | Useful for exploring and manipulating data that fits in memory |
Think of a teacher working with a central school database. The original student records are stored in the school's system. However, a teacher might retrieve a small set of those records into a spreadsheet to carry out additional analysis.
The original records remain in the central system, but the teacher now has a separate copy to work with. This is similar to what we are doing with Snowpark and Pandas.

Why did we use Pandas in our application?
We could have used Snowpark to perform the lookup directly within Snowflake. However, our fruit table contained a relatively small amount of information.
By retrieving the data into a Pandas DataFrame, we could perform individual fruit lookups directly within Python without needing to issue another Snowflake query for every selected fruit.
This does not mean that Pandas is better than Snowpark. They are different tools, and understanding when to use each one is more important than simply knowing that both exist.
6. Converting our Snowpark DataFrame into a Pandas DataFrame
To make this conversion, we used the following line of code:
pd_df = my_dataframe.to_pandas()
my_dataframe is our Snowpark DataFrame. .to_pandas() executes the Snowpark query, retrieves the results and converts them into a Pandas DataFrame. pd_df is the new variable containing the Pandas DataFrame.
We could display this information in Streamlit using:
st.dataframe(pd_df)
The result would look something like this (the rows and index positions are illustrative):
| Index | FRUIT_NAME | SEARCH_ON |
|---|---|---|
| 0 | Apples | Apple |
| 1 | Blueberries | Blueberry |
| 2 | Jack Fruit | Jackfruit |
| 3 | Strawberries | Strawberry |
| 4 | Mango | Mango |

We now have two variables with different responsibilities.
| Variable | What it represents |
|---|---|
my_dataframe | Our Snowpark DataFrame |
pd_df | Our Pandas DataFrame containing the retrieved data |
It is worth noting that .to_pandas() is a Snowpark method that performs this conversion for us.
Revisiting lazy evaluation
In Blog 3, we explored how Snowpark can prepare an operation without immediately executing it. This is called lazy evaluation.
When we initially created my_dataframe, we described the table and columns we wanted to work with. Both .collect() and .to_pandas() trigger execution, but they return different types of results.
.collect()returns a list of Snowpark Row objects..to_pandas()returns a Pandas DataFrame.
In our application, we used .to_pandas() because we wanted to work with the retrieved information directly using Pandas.
7. Finding the correct search value using Pandas
We now have our Pandas DataFrame containing both fruit names and search values. Imagine the customer selects Apples.
fruit_chosen = "Apples"
Our objective is simple: find the row where FRUIT_NAME is Apples and retrieve the corresponding SEARCH_ON value, Apple.
In our completed application, we used the following code:
search_on = pd_df.loc[
pd_df['FRUIT_NAME'] == fruit_chosen,
'SEARCH_ON'
].iloc[0]
When I first looked at this line, it seemed quite complicated. Rather than trying to understand the entire instruction at once, I found it much easier to break it down into three smaller steps.
Step 1 — Find the matching row
pd_df['FRUIT_NAME'] == fruit_chosen
The first part, pd_df['FRUIT_NAME'], identifies the column we want to check. We then compare each value in that column with the fruit selected by the customer.
In Python, a single equals sign (=) assigns a value, while two equals signs (==) compare values.
If the selected fruit is Apples, Pandas checks each row:
| Index | FRUIT_NAME | Matches Apples? |
|---|---|---|
| 0 | Apples | True |
| 1 | Blueberries | False |
| 2 | Jack Fruit | False |
| 3 | Strawberries | False |
| 4 | Mango | False |
The comparison tells Pandas which rows match our condition. We have identified the correct row, but we haven't yet retrieved the search value.
Step 2 — Select the corresponding column using .loc
pd_df.loc[
pd_df['FRUIT_NAME'] == fruit_chosen,
'SEARCH_ON'
]
The .loc indexer allows us to select information from a Pandas DataFrame. In this example, we specify which rows we want using our matching condition, followed by the column we want to retrieve: SEARCH_ON.
The intermediate result would look something like this:
0 Apple
Name: SEARCH_ON
Although we can now see the correct value, Pandas has returned something called a Series. For now, we can think of a Series as a one-dimensional collection of values with index labels, similar to a single column of information.
What we actually want is the individual text value Apple so we can use it in our API request.
Step 3 — Extract the individual value using .iloc[0]
.iloc retrieves information based on numerical position. Python starts counting positions from zero, so .iloc[0] means retrieve the first item.
Because we expect one matching fruit in our lookup, we retrieve the first value from the matching results. Our variable now contains:
search_on = "Apple"
An important distinction is that .iloc[0] retrieves the first item from the filtered results, not necessarily the first row of the original DataFrame.
For example, if the customer selected Blueberries, the filtered Series might look like this:
1 Blueberry
Name: SEARCH_ON
Even though its original index label is 1, .iloc[0] retrieves Blueberry because it is the first item in the filtered results. This is the difference between an index label and a numerical position.

We can now summarise the entire process:
| Code | Purpose |
|---|---|
pd_df['FRUIT_NAME'] == fruit_chosen | Identify the matching rows |
.loc | Select SEARCH_ON from the matching rows |
.iloc[0] | Extract the first matching value |
search_on = | Store the result in a variable |
What originally looked like a complicated line of Python is actually answering quite a simple question: what is the corresponding search value for the fruit selected by the customer?
8. Checking that our code works
Before using the mapped value in our API request, we displayed it in Streamlit.
st.write(
'The search value for ',
fruit_chosen,
' is ',
search_on,
'.'
)
The result in the application was:
The search value for Apples is Apple .

Although this message isn't necessary for the customer's final experience, it was useful during development. It allowed us to check that our Python code was retrieving the correct value before passing it to the API.
Sometimes it is easier to display the contents of a variable and check what is happening rather than trying to understand everything from the code alone. We used a similar approach in my earlier Snowflake blogs, where we checked our data before moving on to the next stage.
9. Using the mapped value in our API request
Previously, we were using the fruit selected by the customer directly.
smoothiefroot_response = requests.get(
"https://my.smoothiefroot.com/api/fruit/"
+ fruit_chosen
)
However, this could produce a URL that the API did not recognise. In the completed application, we changed this to:
smoothiefroot_response = requests.get(
"https://my.smoothiefroot.com/api/fruit/"
+ search_on
)
We have only changed one variable, but this makes an important difference.
| Using fruit_chosen | Using search_on |
|---|---|
| /fruit/Apples | /fruit/Apple |
| /fruit/Blueberries | /fruit/Blueberry |
| /fruit/Jack Fruit | /fruit/Jackfruit |
We can still use the original fruit name when displaying information to the customer.
st.subheader(
fruit_chosen + ' Nutrition Information'
)
Behind the scenes, we use the mapped value when communicating with the API.

The customer doesn't need to know that different systems are using different names. Our application handles that process for them.
10. Bringing the concepts together inside our loop
In Blog 3, we spent time understanding how Python loops work. In Blog 4, we applied that understanding to making an API request for each selected fruit. We are now adding another step inside that same loop.
Here is the relevant section of our application, with the temporary display check omitted for clarity.
if ingredients_list:
ingredients_string = ''
for fruit_chosen in ingredients_list:
ingredients_string += fruit_chosen + ' '
search_on = pd_df.loc[
pd_df['FRUIT_NAME'] == fruit_chosen,
'SEARCH_ON'
].iloc[0]
st.subheader(
fruit_chosen + ' Nutrition Information'
)
smoothiefroot_response = requests.get(
"https://my.smoothiefroot.com/api/fruit/"
+ search_on
)
sf_df = st.dataframe(
data=smoothiefroot_response.json(),
use_container_width=True
)
Although this is a larger block of code, we already understand each of its individual parts. Imagine a customer selects Apples, Blueberries and Mango.
| Iteration | Selected fruit | SEARCH_ON | Information requested |
|---|---|---|---|
| 1 | Apples | Apple | Apple nutrition |
| 2 | Blueberries | Blueberry | Blueberry nutrition |
| 3 | Mango | Mango | Mango nutrition |
During each iteration, Python performs five actions:
- Build the order: Adds the selected fruit to the smoothie order.
- Map the fruit name: Finds the correct API search value using Pandas.
- Create a heading: Uses the original fruit name in Streamlit.
- Retrieve information: Requests nutritional information from the API.
- Display the results: Presents the nutritional information in Streamlit.
Once the loop has finished, the application can prepare the SQL instruction for the completed order and save it when the customer clicks Submit Order.

Notice how we have continued to apply the same principles around indentation that we explored in the previous blogs. The Pandas lookup and API request are inside the loop because we need to repeat these operations for every selected fruit. The SQL INSERT is outside the fruit loop because we only want to save one complete smoothie order.
11. What happens if there is no matching value?
Our lookup assumes that every selected fruit has a matching entry in our Pandas DataFrame. But what would happen if no matching row existed?
Pandas would return an empty result, and .iloc[0] would produce an error because there is no first item to retrieve. Similarly, if there were multiple matching rows with different search values, our code would simply take the first one.
We want each fruit to have one clearly defined search value so that our application knows which value to use. A more developed application would include additional checks to handle these situations. For now, the important thing is to understand that the quality of our data directly affects whether the application works correctly.
12. Looking at the complete application
Across the last three blogs, we have gradually built up our understanding of the smoothie application. Each technology plays a different role.
| Technology | Responsibility |
|---|---|
| Snowflake | Stores available fruits, mapping values and customer orders |
| SQL | Prepares, retrieves and updates data in Snowflake |
| Snowpark | Allows Python to work with Snowflake |
| Pandas | Helps find the corresponding API search value |
| Requests | Retrieves external nutritional information |
| Python | Controls the application logic |
| Streamlit | Provides the interface for the customer |
| GitHub | Stores and manages the application code |
| Streamlit Cloud | Hosts and runs the external application |

Snowflake provides the available fruits, and the customer selects their ingredients through Streamlit. Python uses Pandas to find the correct search value, the Requests library communicates with the API, and Streamlit displays the nutritional information. Finally, when the customer submits their order, Snowflake stores it.
Each technology has its own responsibility, but together they allow us to build a complete data application.
What have we learned?
| Concept | Purpose |
|---|---|
| Data mapping | Establishes a relationship between values used by different systems |
| ALTER TABLE | Can add a new column to an existing table |
| UPDATE | Populates or changes existing values |
| Pandas | Allows us to work with and manipulate data in Python |
| Snowpark DataFrame | Represents data and operations in Snowflake |
| Pandas DataFrame | Allows us to work with retrieved data in Python |
.to_pandas() | Executes the Snowpark query and converts its results to a Pandas DataFrame |
== | Compares values |
.loc | Selects information using labels or matching conditions |
.iloc[0] | Retrieves the first item by its position |
| SEARCH_ON | Stores the value expected by our external API |
One of the most important distinctions from this blog is that Pandas did not create the relationship between Apples and Apple. We prepared that relationship using SQL in Snowflake. Pandas simply helped us find and use the information we had already prepared.
Final thoughts — Bringing my learning together
When I started this Snowflake learning journey, my focus was on understanding databases, loading files and querying information using SQL.
Across these five blogs, I have gradually moved from working with data inside Snowflake to building an application that allows users to interact with that data. Looking back, each part of the series introduced something that became useful later on.
| Blog | Main area of learning |
|---|---|
| Part 1 | Snowflake fundamentals, loading and querying data |
| Part 2 | JSON, VARIANT and nested data |
| Part 3 | Building a data application using Python and Streamlit |
| Part 4 | Retrieving external information using APIs |
| Part 5 | Snowpark, Pandas and mapping data between systems |
What I found particularly valuable was seeing how concepts from earlier parts of my learning became useful again later on.
Understanding JSON helped me when working with API responses. Understanding Python loops and indentation helped me retrieve information for multiple fruits while ensuring that only one complete smoothie order was saved. Understanding SQL helped me prepare the mapping data and store customer orders, while Pandas helped me bring information from different systems together.
When completing the workshop, there were occasions when I could follow the instructions and get the code working without fully understanding why certain lines were needed. Writing these blogs and revisiting the code afterwards has given me an opportunity to address those gaps in my understanding.
Coming from a teaching background, I am reminded of the difference between being able to follow a worked example and being able to explain it or apply the same knowledge to a different problem.
There is still plenty for me to learn, particularly with Python, but I now have a much better understanding of how these different technologies fit together.
My next challenge is to apply this knowledge independently by building my own data application using the Companies House API, taking what I have learned from the smoothie project and applying it to a different real-world problem.
Explore the project
The complete smoothie application code is available on my GitHub repository.
