Python Newbie Q;. Using code below (with correct API Key); the graph is generated correctly, but there's no response, or error message, to the line/question : pandas_ai.run(df, prompt='Which are the 2 happiest countries?')
Could you please help?
first, installed pandasai in command line with "pip install pandasai"
#import the dependencies:
import pandas as pd
from pandasai import PandasAI
from pandasai.llm.openai import OpenAI
#create a dataframe using pandas
df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"gdp": [21400000, 2940000, 2830000, 3870000, 2160000, 1350000, 1780000, 1320000, 516000, 14000000],
"happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0]
})
#print results
#print(df)
OPENAI_API_KEY = "XXX"
llm = OpenAI(api_token=OPENAI_API_KEY)
pandas_ai = PandasAI(llm)
pandas_ai.run(df, prompt='Which are the 2 happiest countries?')
create a chart, using pandasai to set up the prompt
pandas_ai.run(df, "Plot the histogram of countries showing for each the gpd, using different colors for each bar")