Skip to content

Commit

Permalink
Adding option to change the engine used in the query. Using the 'pyth…
Browse files Browse the repository at this point in the history
…on' engine allows checking for substrings when querying, substantially shortening the length of the query
  • Loading branch information
eshwen committed Nov 6, 2020
1 parent 0559b1f commit 59e1857
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fast_plotter/postproc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def __call__(self, row):


def handle_one_df(df, query=None, replacements=[],
combine_dims=[], combine_dims_ignore=None, combine_delim="__"):
combine_dims=[], combine_dims_ignore=None, combine_delim="__", engine_query="numexpr"):
if query:
df.query(query, inplace=True)
df.query(query, inplace=True, engine=engine_query)
if df.empty:
return
df.drop(df.filter(like="Unnamed").columns, axis=1, inplace=True)
Expand All @@ -51,13 +51,13 @@ def handle_one_df(df, query=None, replacements=[],
return df


def query(df, query):
def query(df, query, engine_query="numexpr"):
"""
Keep only rows that satisfy requirements of the query string,
See: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html
"""
logger.info("Applying query: %s", query)
return handle_one_df(df, query=query)
return handle_one_df(df, query=query, engine_query=engine_query)


def rebin(df, axis, mapping, ignore_when_combining=None, rename=None, drop_others=False):
Expand Down

0 comments on commit 59e1857

Please sign in to comment.