Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

Data is the new oil, but only when refined. An AI chatbot can be your refinery.
In today’s data-driven world, we are drowning in spreadsheets — from sales reports and customer logs to academic scores and HR records. What if you could ask your data questions in plain English, and get the answers?
Welcome to the world of DataFrame Chatbots — smart assistant powered by Python, AI, and your CSV/Excel files.
In this blog you will learn how to:
The goal is to turn data into information, and information into insight.
In today’s world, data is everywhere — sales report, employee records, customer logs, survey results — usually stored as spreadsheets. While tools like Excel and Pandas are powerful, they still require:
Now Imagine this :
Instead of writing formulas or code, you just ask your spreadsheet a question — and it replies like a human
That’s the power of DataFrame Chatbot. It lets you
| Tool | Purpose |
|---|---|
| pandas | Handle Tabular data |
| streamlit | Frontend app with chat UI |
| langchain | Agent framework and orchestration |
| langchain_ollama | Interface to local LLMs via Ollama |
| gemma:2b (Ollama) | Small, efficient local language model |
Save as app.py
import pandas as pd
import streamlit as st
from langchain.agents import AgentType
from langchain_experimental.agents import create_pandas_dataframe_agent
from langchain_ollama import ChatOllama
# Streamlit UI setup
st.set_page_config(page_title="DataFrame Chat", page_icon="đź’¬", layout="centered")
st.title("🤖 DataFrame ChatBot ")
st.write("Developer Prem Kumar")
# Read CSV or Excel
def read_data(file):
if file.name.endswith(".csv"):
return pd.read_csv(file)
else:
return pd.read_excel(file)
# Initialize session state
if "chat_history" not in st.session_state:
st.session_state.chat_history = []
if "df" not in st.session_state:
st.session_state.df = None
# File upload
uploaded_file = st.file_uploader("Choose a file", type=["csv", "xlsx", "xls"])
if uploaded_file:
st.session_state.df = read_data(uploaded_file)
st.write("DataFrame Preview:")
st.dataframe(st.session_state.df.head())
# Show chat history
for message in st.session_state.chat_history:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# User input
user_prompt = st.chat_input("Enter your prompt.✨")
if user_prompt:
st.chat_message("user").markdown(user_prompt)
st.session_state.chat_history.append({"role": "user", "content": user_prompt})
# Load local LLM from Ollama
llm = ChatOllama(model="gemma:2b", temperature=0)
# Create agent with Pandas + LangChain
pandas_df_agent = create_pandas_dataframe_agent(
llm,
st.session_state.df,
verbose=True,
agent_type=AgentType.OPENAI_FUNCTIONS,
allow_dangerous_code=True
)
# Combine messages for agent context
messages = [{"role": "system", "content": "You are a helpful assistant"}, *st.session_state.chat_history]
# Get response
response = pandas_df_agent.invoke(messages)
assistant_response = response["output"]
# Display and save assistant response
st.session_state.chat_history.append({"role": "assistant", "content": assistant_response})
with st.chat_message("assistant"):
st.markdown(assistant_response)
Once your file is uploaded and the app is running, ask:
AI that understands your spreadsheets is like Excel with superpowers

| Sector | Use Case |
|---|---|
| Retail | Chat with monthly sales reprot |
| Education | Analyze student performance spreadsheets |
| HR | Interact with employee data |
| Finance | Summarize large accounting files |
| NGOs | Track impact and donations via Excel |
You can share this app internally or deploy it locally with:
streamlit run app.py
With Langchain, Ollama and Stramlit, building a powerful, private AI chatbot for your spreadsheets is easier than ever — no cloud, no API keys, no limitations
Own your model. Own your Data. Own your AI