Created
May 26, 2021 00:02
-
-
Save schlerp/7fc368cc1e3518d7c8bdf633a5621b54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
def __init__(self, *args, **kwargs): | |
self.df: pd.DataFrame = None | |
def get_sample(self, *args, n_rows: int = 100, **kwargs): | |
return self.df.sample(*args, n=n_rows, **kwargs) | |
class OutputNode(Node): | |
_node_type = "OutputNode" | |
pass | |
class OutputCSVNode(OutputNode): | |
_node_subtype = "csv" | |
_node_name = "CSV Output" | |
def __init__(self, output_path: str, include_index: bool = False): | |
super().__init__() | |
self.output_path = output_path | |
self.include_index = include_index | |
def _process(self, input_node: Node): | |
self.df = input_node.df | |
self.df.to_csv(self.output_path, index=self.include_index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment