I have been using PandasAI together with OpenAI models (both GPT-4o and GPT-3.5-turbo) to query Excel data using plain English questions.
For several days, everything worked perfectly. I had a set of test queries that always gave me the right answers.
But around late June 2025, some queries that used to work started breaking. Nothing changed on my end:
- Same Excel files with identical data
- Same code and prompts
- Same query text
My current setup:
- Loading Excel data with
pandas.read_excel() - Using
pandas-ailibrary withSmartDataframeorSmartDatalake - OpenAI API for GPT models
- Custom prompts that add formatting rules
- Field descriptions and custom parser
What I notice:
- Query works one day, fails the next day with same inputs
- The AI seems to generate bad Python code now (like trying to divide text strings or calling string methods on numbers)
Here’s my code:
from pandasai import SmartDataframe, SmartDatalake
from pandasai.llm.openai import OpenAI
# Setup OpenAI connection
model = OpenAI(api_token="my_api_key", temperature=0, model="gpt-4o")
# Custom formatting instructions
format_instructions = "Numbers over 1000 need commas, rates and percentages need % symbol"
column_info = (
"Available columns: (Product Type, Event Count, Mean Value 2023/2024, "
"Class X, Class Y, Success Rate (% 2f), etc.)"
)
# Choose configuration based on query type
if "percentage" not in query_input.lower():
data_agent = SmartDataframe(
st.session_state.main_data,
config={
"llm": model,
"conversational": False,
"custom_prompts": {
"data_analysis": (
"Create grouped summaries with percentages when needed, "
"format output as tables by default."
)
},
"verbose": True,
"field_descriptions": descriptions,
"response_parser": MyCustomParser,
},
)
final_query = query_input + format_instructions + " Display as table."
else:
data_agent = SmartDatalake(
[st.session_state.main_data, st.session_state.backup_data],
config={
"llm": model,
"conversational": False,
"custom_prompts": {
"data_analysis": (
"Create grouped summaries with percentages when needed, "
"format output as tables by default."
)
},
"verbose": True,
"field_descriptions": descriptions,
"response_parser": MyCustomParser,
},
)
final_query = query_input + column_info + format_instructions + " Display as table."
# Execute the query
result, timeout_occurred = execute_with_timer(data_agent, final_query)
Anyone else seeing this issue with PandasAI and OpenAI recently?