Context
TidyContext
Parameters supported by TidyDataFrame contextual operations.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of DataFrame. |
count |
bool
|
Whether to perform count operations. |
display |
bool
|
Whether to perform display operations. |
limit |
int
|
Default all display operations to display only |
log_handlers |
list[TidyLogHandler]
|
Sequence of TidyLogHandler instances to configure for TidyDataFrame. |
Examples:
>>> # assuming PySpark DataFrame is loaded
>>> spark_data = ...
>>>
>>> # default configuration
>>> default_context = TidyContext()
>>> default_dataframe = TidyDataFrame(spark_data, default_context)
>>>
>>> # simple contextual configuration
>>> basic_context = TidyContext(
>>> name="ContextDataFrame",
>>> count=False,
>>> limit=10
>>> )
>>> basic_dataframe = TidyDataFrame(spark_data, basic_context)
>>>
>>> # attaching log handlers
>>> logging_context = TidyContext(
>>> name="LoggingHandlers",
>>> log_handlers=[
>>> TidyLogHandler(),
>>> TidyFileHandler("example.log"),
>>> TidyMemoHandler("serialized_example.log")
>>> ]
>>> )
>>> logging_dataframe = TidyDataFrame(spark_data, logging_context)
load
classmethod
load(context: str | Path | dict) -> TidyContext
Create TidyContext from pre-configured context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
str | Path | dict
|
Reference to object containing TidyContext attributes. If |
required |
Returns:
Type | Description |
---|---|
TidyContext
|
Instance of TidyContext configured with provided parameters. |
Source code in src/tidy_tools/dataframe/context.py
save
Save attributes as serialized object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str | Path | None
|
Optional path to save context configuration. This file can be
loaded using the |
None
|
Returns:
Type | Description |
---|---|
dict | None
|
If no |
Raises:
Type | Description |
---|---|
Exception
|
If there is an error while writing to |