datopy.inspection.display#
- display( )[source]#
Display an informative representation of multiple objects side-by-side.
Warning
This function uses eval() to render expressions it receives as strings. Access to variables in the global namespace is controlled by globs. Take care to only pass trusted expressions to the function.
- Parameters:
args (tuple) – Tuple of expressions to evaluate and display.
globs (dict[str, Any], default=None) – Global namespace, to give eval() access to nonlocals passed by name.
bold (bool, default=True) – Option to enable/disable string styling.
Examples
>>> import numpy as np >>> import pandas as pd >>> from datopy.inspection import display, make_df
Data frame example
>>> df1 = make_df('AB', [1, 2]); df2 = make_df('AB', [3, 4]) >>> display('df1', 'df2', 'pd.concat([df1, df2])', globs=globals(), bold=False) df1 --- (2, 2) --- A B 1 A1 B1 2 A2 B2 df2 --- (2, 2) --- A B 3 A3 B3 4 A4 B4 pd.concat([df1, df2]) --- (4, 2) --- A B 1 A1 B1 2 A2 B2 3 A3 B3 4 A4 B4
Matrix example
>>> A = np.array([[1, 3], [2, 4]]); x = np.array([[0, 1]]) >>> display("A", "x.T", "np.dot(A, x.T)", globs=globals(), bold=False) A --- (2, 2) --- array([[1, 3], [2, 4]]) x.T --- (2, 1) --- array([[0], [1]]) np.dot(A, x.T) --- (2, 1) --- array([[3], [4]])