Machine Learning
Pandas-AI (pandas 활용을 chatGPT 명령에 따라 실행)
Dan-k
2023. 5. 8. 01:24
반응형
Chat-GPT열풍은 계속된다!!!
Pandas의 컨트롤을 드디어...chat-GPT명령으로 실행시킬수 있는 툴이 나왔다!!!!
나의 데이터를 chat-GPT가 인식해 핸들링하게 하는 방법인데...기가 막히다.
1. 데이터 핸들링 -> 특정조건에 맞는 데이터 추출, 조인도 가능할 듯
2. plotting -> 원하는 그림 시각화
이제 쿼리도...날릴 필요가 없어지는 날이 오지 않을까........헛.....
장점
코딩을 못해도 아주 단순하게....쉬운 방법으로 결과물을 출력할 수 있다.
단점
실행된 결과에 대한 신뢰성 검증 필요
사용예시
import pandas as pd
from pandasai import PandasAI
# 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]
})
# Instantiate a LLM
from pandasai.llm.openai import OpenAI
llm = OpenAI()
pandas_ai = PandasAI(llm)
pandas_ai.run(df, prompt='Which are the 5 happiest countries?')
결과
6 Canada
7 Australia
1 United Kingdom
3 Germany
0 United States
Name: country, dtype: object
pandas_ai.run(
df,
"Plot the histogram of countries showing for each the gpd, using different colors for each bar",
)
참조
https://github.com/gventuri/pandas-ai
728x90
반응형
LIST