Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed _core property on SmartDataframe that causes maximum recursion depth exceeded #1388

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

andeplane
Copy link
Contributor

@andeplane andeplane commented Oct 8, 2024

I ran into RecursionError: maximum recursion depth exceeded when using SmartDataframe and found the issue is caused by a call to __getattr__ trying to access _core which does not exist, but it calls __getattr__ repeatedly.

There may be something I don't understand in the code here, and that this has a reason to exist, but this solved my problems.

To reproduce the problem, create a smart data frame with e.g.

import os
import pandas as pd
from pandasai import SmartDataframe

# Sample DataFrame
sales_by_country = pd.DataFrame({
    "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
    "revenue": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})

# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os.environ["PANDASAI_API_KEY"] = "<insert_key>"

df = SmartDataframe(sales_by_country)
df.anyproperty

to see that it throws this error.

  • Closes #xxxx (Replace xxxx with the GitHub issue number).
  • Tests added and passed if fixing a bug or adding a new feature.
  • All code checks passed.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 8, 2024
@gventuri gventuri merged commit e3f30b9 into Sinaptik-AI:main Oct 16, 2024
5 of 9 checks passed
@andeplane andeplane deleted the patch-1 branch October 31, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants