towhee.dag.dataframe_repr.DataFrameRepr¶
- class towhee.dag.dataframe_repr.DataFrameRepr(name: str, columns: List[VariableRepr])[source]¶
Bases:
BaseRepr
A DataFrameRepr represents a single dataframe within a graph.
A single dataframe is composed of multiple individual variables, each of which is required in the next operator stage within the graph.
- Parameters:
name (str) – The representation name.
columns (List[VariableRepr]) – The columns that the DataFrameRepr contains.
Methods
Generate a DataframeRepr from a description dict.
inject_template
Check if the src is a valid YAML file to describe a component in Towhee.
Load the representation(s) information from a local YAML file.
Load the information for the representation.
Load the representation(s) information from a YAML file (pre-loaded as string).
Load the representation information from a remote YAML file.
render_template
Attributes
columns
name
- __init__(name: str, columns: List[VariableRepr])[source]¶
- static from_dict(info: Dict[str, Any]) DataFrameRepr [source]¶
Generate a DataframeRepr from a description dict.
- Parameters:
info (Dict[str, Any]) – A dict to describe the Dataframe.
- Returns:
- (towhee.dag.DataFrameRepr)
The DataFrameRepr object.
- static is_valid(info: Dict[str, Any], essentials: Set[str]) bool ¶
Check if the src is a valid YAML file to describe a component in Towhee.
- Parameters:
info (Dict[str, Any]) – The dict loaded from the source file.
essentials (Set[str]) – The essential keys that a valid YAML file should contain.
- Returns:
- (bool)
Return True if the src file is a valid YAML file to describe a component in Towhee, else False.
- static load_file(file: str) dict ¶
Load the representation(s) information from a local YAML file.
- Parameters:
file (str) – The file path.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.
- static load_src(file_or_src: str) dict ¶
Load the information for the representation. We support file from local file/HTTP/HDFS.
- Parameters:
file_or_src (str) – The source YAML file or the URL points to the source file or a str loaded from source file.
- Returns:
- (dict)
The YAML file loaded as dict.
- static load_str(string: str) dict ¶
Load the representation(s) information from a YAML file (pre-loaded as string).
- Parameters:
string (str) – The string pre-loaded from a YAML.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.
- static load_url(url: str) dict ¶
Load the representation information from a remote YAML file.
- Parameters:
url (str) – The url points to the remote YAML file.
- Returns:
- (dict)
The dict loaded from the YAML file that contains the representation information.