forked from Sinaptik-AI/pandas-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwith_privacy_enforced.py
46 lines (43 loc) · 1.01 KB
/
with_privacy_enforced.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Example of using PandasAI with a Pandas DataFrame"""
import pandas as pd
from pandasai import PandasAI
from pandasai.llm.openai import OpenAI
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],
}
)
llm = OpenAI()
pandas_ai = PandasAI(llm, verbose=True, conversational=False)
response = pandas_ai.run(
df,
"Calculate the sum of the gdp of north american countries",
enforce_privacy=True,
is_conversational_answer=True,
)
print(response)
# Output: 26200000