Ai utils
AIMethodWrapper
This class wraps the AI utility functions to allow them to be used directly on DataFrame instances. An instance of this class is created each time the utility functions are accessed, with the DataFrame and SparkAI instance passed to it.
Source code in pyspark_ai/ai_utils.py
__init__(spark_ai, df_instance)
Initialize the AIMethodWrapper with the given SparkAI and DataFrame instance.
Args: spark_ai: The SparkAI instance containing the AI utility methods. df_instance: The DataFrame instance on which the utility methods will be used.
Source code in pyspark_ai/ai_utils.py
explain(cache=True)
Explain the DataFrame.
Args:
cache: Indicates whether to utilize a cache for this method.
If True, fetches cached data, if available.
If False, retrieves fresh data and updates cache.
Returns: A string explanation of the DataFrame.
Source code in pyspark_ai/ai_utils.py
plot(desc=None, cache=True)
Plot the DataFrame.
Args:
desc: A string description specifying the plot.
cache: Indicates whether to utilize a cache for this method.
If True, fetches cached data, if available.
If False, retrieves fresh data and updates cache.
Source code in pyspark_ai/ai_utils.py
transform(desc, cache=True)
Transform the DataFrame using the given description.
Args:
desc: A string description specifying the transformation.
cache: Indicates whether to utilize a cache for this method.
If True, fetches cached data, if available.
If False, retrieves fresh data and updates cache.
Returns: The transformed DataFrame.
Source code in pyspark_ai/ai_utils.py
verify(desc, cache=True)
Verify the DataFrame using the given description.
Args:
desc: A string description specifying what to verify in the DataFrame.
cache: Indicates whether to utilize a cache for this method.
If True, fetches cached data, if available.
If False, retrieves fresh data and updates cache.
Returns: True, if DataFrame tranformations are valid, otherwise False
Source code in pyspark_ai/ai_utils.py
AIUtils
This class is a descriptor that is used to add AI utility methods to DataFrame instances. When the utility methods are accessed, it returns a new AIMethodWrapper instance with the DataFrame and SparkAI instance passed to it.
Source code in pyspark_ai/ai_utils.py
__get__(instance, owner)
This method is called when the AI utility methods are accessed on a DataFrame instance. It returns a new AIMethodWrapper instance with the DataFrame instance and SparkAI passed to it.
Args: instance: The DataFrame instance on which the utility methods are being accessed. owner: The class (DataFrame) to which this descriptor is added.
Returns: A new AIMethodWrapper instance.
Source code in pyspark_ai/ai_utils.py
__init__(spark_ai)
Initialize the AIUtils descriptor with the given SparkAI.
Args: spark_ai: The SparkAI instance containing the AI utility methods.