OpenAI and python pandasai

Hi, i am new to Python, but trying out the PandasAI demo.

Here is the code i am running:
import pandas as pd
from pandasai import PandasAI
from pandasai.llm.openai import OpenAI

Sample DataFrame

df = pd.DataFrame({
“country”: [“United States”, “United Kingdom”, “France”, “Germany”, “Italy”, “Spain”, “Canada”, “Australia”, “Japan”, “China”],
“gdp”: [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504, 1490967855104, 4380756541440, 14631844184064],
“happiness_index”: [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]
})

OPENAI_API_KEY = “XXXXXX”
llm = OpenAI(api_token=OPENAI_API_KEY)

pandas_ai = PandasAI(llm)
pandas_ai.run(df, prompt=‘Which are the 5 happiest countries?’)

When i run this in pycharm i get process finished with exit code 0 wich i understand is an indication that the code is running correct. But i cant see any results from the prompt. Anybody who knows where i am going wrong?

Best regards, Mads

You aren’t telling it to print anything. Check their examples docs

1 Like

Thank you. That was easy :face_with_open_eyes_and_hand_over_mouth: