Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Llama Index
Commits
bd8e39ff
Unverified
Commit
bd8e39ff
authored
11 months ago
by
Ayush Lall
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
[Fix]: PandasQueryEngine can now execute 'pd.*' functions (#12240)
parent
f513d6c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-core/llama_index/core/query_engine/pandas/output_parser.py
+3
-2
3 additions, 2 deletions
...ore/llama_index/core/query_engine/pandas/output_parser.py
with
3 additions
and
2 deletions
llama-index-core/llama_index/core/query_engine/pandas/output_parser.py
+
3
−
2
View file @
bd8e39ff
...
@@ -30,6 +30,7 @@ def default_output_processor(
...
@@ -30,6 +30,7 @@ def default_output_processor(
return
output
return
output
local_vars
=
{
"
df
"
:
df
}
local_vars
=
{
"
df
"
:
df
}
global_vars
=
{
"
np
"
:
np
,
"
pd
"
:
pd
}
output
=
parse_code_markdown
(
output
,
only_last
=
True
)[
0
]
output
=
parse_code_markdown
(
output
,
only_last
=
True
)[
0
]
...
@@ -44,13 +45,13 @@ def default_output_processor(
...
@@ -44,13 +45,13 @@ def default_output_processor(
if
module_end_str
.
strip
(
"'
\"
"
)
!=
module_end_str
:
if
module_end_str
.
strip
(
"'
\"
"
)
!=
module_end_str
:
# if there's leading/trailing quotes, then we need to eval
# if there's leading/trailing quotes, then we need to eval
# string to get the actual expression
# string to get the actual expression
module_end_str
=
safe_eval
(
module_end_str
,
{
"
np
"
:
np
}
,
local_vars
)
module_end_str
=
safe_eval
(
module_end_str
,
global_vars
,
local_vars
)
try
:
try
:
# str(pd.dataframe) will truncate output by display.max_colwidth
# str(pd.dataframe) will truncate output by display.max_colwidth
# set width temporarily to extract more text
# set width temporarily to extract more text
if
"
max_colwidth
"
in
output_kwargs
:
if
"
max_colwidth
"
in
output_kwargs
:
pd
.
set_option
(
"
display.max_colwidth
"
,
output_kwargs
[
"
max_colwidth
"
])
pd
.
set_option
(
"
display.max_colwidth
"
,
output_kwargs
[
"
max_colwidth
"
])
output_str
=
str
(
safe_eval
(
module_end_str
,
{
"
np
"
:
np
}
,
local_vars
))
output_str
=
str
(
safe_eval
(
module_end_str
,
global_vars
,
local_vars
))
pd
.
reset_option
(
"
display.max_colwidth
"
)
pd
.
reset_option
(
"
display.max_colwidth
"
)
return
output_str
return
output_str
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment