Skip to content

Commit

Permalink
Merge pull request Sinaptik-AI#29 from Lorenzobattistela/fix-Example
Browse files Browse the repository at this point in the history
Fix example
  • Loading branch information
gventuri authored May 4, 2023
2 parents c566beb + fd53b9c commit 3c2e1e3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pip install pandasai

## Usage

>Disclaimer: GDP data was collected from [this source](https://ourworldindata.org/grapher/gross-domestic-product?tab=table), published by World Development Indicators - World Bank (2022.05.26) and collected at National accounts data - World Bank / OECD. It relates to the year of 2020. Happiness indexes were extracted from [the World Happiness Report](https://ftnnews.com/images/stories/documents/2020/WHR20.pdf). Another useful [link](https://data.world/makeovermonday/2020w19-world-happiness-report-2020).
PandasAI is designed to be used in conjunction with Pandas. It makes Pandas conversational, allowing you to ask questions about your data and get answers back, in the form of Pandas DataFrames. For example, you can ask PandasAI to find all the rows in a DataFrame where the value of a column is greater than 5, and it will return a DataFrame containing only those rows:

```python
Expand All @@ -34,8 +36,8 @@ from pandasai import PandasAI
# Sample DataFrame
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]
"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]
})

# Instantiate a LLM
Expand All @@ -49,11 +51,11 @@ pandas_ai.run(df, prompt='Which are the 5 happiest countries?')
The above code will return the following:

```
0 United States
6 Canada
7 Australia
1 United Kingdom
3 Germany
0 United States
Name: country, dtype: object
```

Expand All @@ -66,7 +68,7 @@ pandas_ai.run(df, prompt='What is the sum of the GDPs of the 2 unhappiest countr
The above code will return the following:

```
14516000
19012600725504
```

You can also ask PandasAI to draw a graph:
Expand Down
22 changes: 11 additions & 11 deletions examples/data/sample_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
"China",
],
"gdp": [
21400000,
2940000,
2830000,
3870000,
2160000,
1350000,
1780000,
1320000,
516000,
14000000,
19294482071552,
2891615567872,
2411255037952,
3435817336832,
1745433788416,
1181205135360,
1607402389504,
1490967855104,
4380756541440,
14631844184064,
],
"happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0],
"happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12],
}
2 changes: 1 addition & 1 deletion examples/from_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
pandas_ai = PandasAI(llm, verbose=True, conversational=False)
response = pandas_ai.run(df, "Calculate the sum of the gdp of north american countries")
print(response)
# Output: 26200000
# Output: 20901884461056
2 changes: 1 addition & 1 deletion examples/with_privacy_enforced.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"Calculate the sum of the gdp of north american countries",
)
print(response)
# Output: 26200000
# Output: 20901884461056
Binary file modified images/histogram-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3c2e1e3

Please sign in to comment.