[Python] My Jupyter Notebook crashes when I try to use PandasAI

Discussão em 'Python' iniciado por Stack, Julho 25, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página