Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for var_name, var_val in callers_local_vars:
if var_val is df_object:
df_name = var_name
dataframes[df_name] = df_object
# Add the dictionary of positional args to the kwargs
if any([key in kwargs.keys() for key in dataframes.keys()]):
logger.warning(
"Duplicate DataFrame names were provided, duplicates were ignored."
)
kwargs = {**kwargs, **dataframes}
pandas_gui = PandasGUI(**kwargs)
if store.settings.block:
pandas_gui.app.exec_()
return pandas_gui
def show(*args, settings: dict = {}, **kwargs):
"""
Create and show a PandasGUI window with all the DataFrames passed. *args and **kwargs should all be DataFrames
Args:
*args: These should all be DataFrames. The GUI uses stack inspection to get the variable name to use in the GUI
block (bool): Indicates whether to run app._exec on the PyQt application to block further execution of script
**kwargs: These should all be DataFrames. The key is the desired name and the value is the DataFrame object
"""
for key, value in settings.items():
setattr(store.settings, key, value)
# Get the variable names in the scope show() was called from
callers_local_vars = inspect.currentframe().f_back.f_locals.items()
# Make a dictionary of the DataFrames from the position args and get their variable names using inspect
dataframes = {}
for i, df_object in enumerate(args):
df_name = "untitled" + str(i + 1)
for var_name, var_val in callers_local_vars:
if var_val is df_object:
df_name = var_name
dataframes[df_name] = df_object
# Add the dictionary of positional args to the kwargs