I have a jupyter notebook that I’m trying to run using the pandasai library. Here is the code:
# Import Libraries
import pandas as pd
from pandasai import Agent, SmartDataframe
import os
#from pandasai.llm import OpenAI
from pandasai.llm.openai import OpenAI
from pandasai.smart_datalake import SmartDatalake
os.environ['OPENAI_API_KEY'] = '<My OPENAI Key>'
os.environ["PANDASAI_API_KEY"] = "<My Pandas API Key>"
# Load the data
df = pd.read_excel('<Path to Excel spreadsheet>', sheet_name='Factors', parse_dates=True, index_col='Date')
llm = OpenAI(api_token=os.environ['OPENAI_API_KEY'],model='gpt-4o')
# Create a SmartDataframe
sdf = SmartDataframe(df, config={"llm": llm})
sdf.head()
Running the head method causes the Jupyter Kernel to immediately crash and restart.
I have no idea how to debug this. Any help appreciated.