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

NameError: name 're' is not defined #27

Open
abhigarg opened this issue Apr 7, 2023 · 1 comment
Open

NameError: name 're' is not defined #27

abhigarg opened this issue Apr 7, 2023 · 1 comment

Comments

@abhigarg
Copy link

abhigarg commented Apr 7, 2023

This error occurs when I am asking it to find sum of rows of certain column after filtering the rows by value of another column. In case of value being string, its applying the flag=re.IGNORECASE which is throwing the error re is not defined

This is the command returned by chatGPT:
df[df['Description/Narration'].str.contains('MONTHLY INTEREST', flags=re.IGNORECASE)]['Credit(Cr.)'].sum()

I asked this question:
df_table.llm.query("What is the total credit with MONTHLY INTEREST in Description?")

@ccurme
Copy link
Owner

ccurme commented Apr 8, 2023

Hi @abhigarg

Thanks for raising this issue. NameErrors like this can arise if code generated in .query references something outside the namespace of that method-- in this case the package re.

I've created #28 to capture this issue generally. A workaround for now is to add an instruction in the query to "import any packages you need." I was able to reproduce your issue and this workaround solved it for me. Streamlining this will require some development in yolopandas that is described in #28.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants