Find answers from the community

Updated 2 months ago

Pandas

hello, please help. Im currently using subquestion query with pandasquery as tools. but when the query is "What date is today?" the pandas generate code returning error, here the generate code

Pandas Instructions:
Plain Text
df[(df['DATE'] == datetime.date.today()) & (df['AIRPORT'] == 'CGK')]['realization_passenger'].sum()

df[(df['DATE'] == datetime.date.today()) & (df['AIRPORT'] == 'CGK')]['realization_passenger'].sum()
Traceback (most recent call last):
File "/Users/digitalservicet3/miniforge3/lib/python3.10/site-packages/llama_index/query_engine/pandas_query_engine.py", line 60, in default_output_processor
raise e
File "/Users/digitalservicet3/miniforge3/lib/python3.10/site-packages/llama_index/query_engine/pandas_query_engine.py", line 58, in default_output_processor
return str(eval(module_end_str, {"np": np}, local_vars))
File "<string>", line 1, in <module>
NameError: name 'datetime' is not defined
Pandas Output: There was an error running the output as Python code. Error message: name 'datetime' is not defined

error is because it not generate the import first. how im suppose to do to solve that error,
thankyou
L
d
2 comments
Yea that's tricky πŸ€” if you import datetime before running the query, does it work?

The pandas engine is still a little beta tbh
yah, it's already import at a main code. but still not recognize in the running sub question query. oiya the llamahub also can connect to pandas ai, I have already test pandas ai and it can run that task smoothly, but can pandas ai be a tools to be called on subquestion query?
Add a reply
Sign up and join the conversation on Discord