Sinaptik-AI / pandas-ai

Chat with your database (SQL, CSV, pandas, polars, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.
https://pandas-ai.com
Other
12.6k stars 1.22k forks source link

output issue #1353

Open anilmadishetty2498 opened 2 weeks ago

anilmadishetty2498 commented 2 weeks ago

System Info

python==3.11.7

🐛 Describe the bug

df.chat('what is total revenue by year')

the output is as below:

         Year   Total Revenue

Year
2023 2024 3.990066e+07 2024 2023 3.435840e+07

in the above output, there is a clash between index and column years, how to drop index year...

dosubot[bot] commented 2 weeks ago

To drop the index and avoid the clash between the index and the column "Year" in the output DataFrame, you can reset the index after receiving the DataFrame from the df.chat method. Here's how you can do it:

# Assuming df is your SmartDataframe instance
result = df.chat('what is total revenue by year')

# Reset the index to drop the current index
result = result.reset_index(drop=True)

print(result)

This will remove the index and make "Year" a regular column, resolving the clash.

To continue talking to Dosu, mention @dosu.

anilmadishetty2498 commented 2 weeks ago

index data is correct than column data