Timer
Provides a timer utility for tracking the elapsed time of steps within a Pandas method chain.
Note that these functions rely on the pdchecks.enable_checks
option being enabled in the Pandas configuration, as it is by default.
_display_line(line, lead_in=None, colors={})
Displays a line of text with optional formatting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line
|
str
|
The text to display. |
required |
lead_in
|
Union[str, None]
|
The optional text to display before the main text. |
None
|
colors
|
Dict
|
An optional dictionary containing color options for the text and lead-in text. See syntax in docstring for _render_text(). |
{}
|
Returns:
Type | Description |
---|---|
None
|
None |
get_mode()
Returns whether Pandas Checks is currently running checks and assertions.
Returns:
Type | Description |
---|---|
Dict[str, bool]
|
A dictionary containing the current settings. |
print_time_elapsed(start_time, lead_in='⏱️ Time elapsed', units='auto')
Displays the time elapsed since start_time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time
|
float
|
The index time when the stopwatch started, which comes from the Pandas Checks start_timer() |
required |
lead_in
|
Union[str, None]
|
Optional text to print before the elapsed time. |
'⏱️ Time elapsed'
|
units
|
str
|
The units in which to display the elapsed time. Allowed values: "auto", "milliseconds", "seconds", "minutes", "hours" or shorthands "ms", "s", "m", "h" |
'auto'
|
Returns:
Type | Description |
---|---|
None
|
None |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Note
If you change the default values for this function's argument,
change them in .check.print_time_elapsed
too in DataFrameChecks and SeriesChecks
so they're exposed to the user.
start_timer(verbose=False)
Starts a Pandas Checks stopwatch to measure run time between operations, such as steps in a Pandas method chain. Use print_elapsed_time() to get timings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose
|
bool
|
Whether to print a message that the timer has started. |
False
|
Returns:
Type | Description |
---|---|
float
|
Timestamp as a float |