Added Pandas at, iat getter and setter nodes.

This commit is contained in:
HowToSD
2025-03-05 18:25:21 -08:00
parent ed1cef099e
commit be88fd6caa
75 changed files with 2826 additions and 47 deletions
+43
View File
@@ -0,0 +1,43 @@
from typing import Any, Dict
from datetime import datetime
class PyDatetimeToString:
"""
Converts a Python datetime.datetime value to a Python string
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("PYDATETIME", {}),
"date_format": ("STRING", {"default":"%Y-%m-%d %H:%M:%S", "multiline": False}),
}
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: datetime, date_format: str) -> tuple:
"""
Converts a Python datetime.datetime value to a Python string
Args:
value (str): String value to convert.
Returns:
tuple: A tuple containing the converted value.
"""
return (datetime.strftime(value, date_format),)
+40
View File
@@ -0,0 +1,40 @@
from typing import Any, Dict
import datetime
class PyFloatToString:
"""
Converts a Python float value to a Python string
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
}
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: float) -> tuple:
"""
Converts a Python float value to a Python string
Args:
value (float): Float value to convert.
Returns:
tuple: A tuple containing the converted value.
"""
return (str(value),)
+40
View File
@@ -0,0 +1,40 @@
from typing import Any, Dict
class PyIntToString:
"""
Converts a Python int value to a Python string
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: int) -> tuple:
"""
Converts a Python int value to a Python string
Args:
value (int): Int value to convert.
Returns:
tuple: A tuple containing the converted value.
"""
return (str(value),)
+43
View File
@@ -0,0 +1,43 @@
from typing import Any, Dict
from datetime import datetime
class PyStringToDatetime:
"""
Converts a Python string to a Python datetime.datetime.
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("STRING", {"default":"", "multiline": False}),
"date_format": ("STRING", {"default":"%Y-%m-%d %H:%M:%S", "multiline": False}),
}
}
RETURN_TYPES: tuple = ("PYDATETIME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: str, date_format: str) -> tuple:
"""
Converts a Python string to Python datetime.datetime.
Args:
value (str): String value to convert.
Returns:
tuple: A tuple containing the dictionary.
"""
return (datetime.strptime(value, date_format),)
+40
View File
@@ -0,0 +1,40 @@
from typing import Any, Dict
class PyStringToFloat:
"""
Converts a Python string to a float.
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("STRING", {"default":"", "multiline": False})
}
}
RETURN_TYPES: tuple = ("FLOAT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: str) -> tuple:
"""
Converts a Python string to a float.
Args:
value (str): String value to convert.
Returns:
tuple: A tuple containing the dictionary.
"""
return (float(value),)
+40
View File
@@ -0,0 +1,40 @@
from typing import Any, Dict
class PyStringToInt:
"""
Converts a Python string to an int.
category: Python wrapper
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `create` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"value": ("STRING", {"default":"", "multiline": False})
}
}
RETURN_TYPES: tuple = ("INT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, value: str) -> tuple:
"""
Converts a Python string to an int.
Args:
value (str): String value to convert.
Returns:
tuple: A tuple containing the dictionary.
"""
return (int(value),)
@@ -0,0 +1,57 @@
from typing import Any, Dict
import pandas as pd
import datetime
class PandasAtDatetime:
"""
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),)
}
}
RETURN_TYPES: tuple = ("PYDATETIME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
value = dataframe.at[row_index, column_label]
return (value.to_pydatetime(),)
+56
View File
@@ -0,0 +1,56 @@
from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasAtFloat:
"""
Selects a cell from a pandas DataFrame and output as a Python float.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),)
}
}
RETURN_TYPES: tuple = ("FLOAT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
value = dataframe.at[row_index, column_label]
return (float(value),)
+56
View File
@@ -0,0 +1,56 @@
from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasAtInt:
"""
Selects a cell from a pandas DataFrame and output as a Python int.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),)
}
}
RETURN_TYPES: tuple = ("INT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
value = dataframe.at[row_index, column_label]
return (int(value),)
@@ -0,0 +1,62 @@
from typing import Any, Dict
import pandas as pd
import datetime
class PandasAtSetDatetime:
"""
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),),
"data": ("PYDATETIME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str,
data: datetime.datetime) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
data: datetime.datetime (datetime.datetime): The value to set in the cell.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
dataframe.at[row_index, column_label] = data
return (dataframe,)
@@ -0,0 +1,61 @@
from typing import Any, Dict
import pandas as pd
class PandasAtSetFloat:
"""
Sets a Python float data in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),),
"data": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str,
data: float) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
data: float (float): The value to set in the cell.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
dataframe.at[row_index, column_label] = data
return (dataframe,)
@@ -0,0 +1,61 @@
from typing import Any, Dict
import pandas as pd
class PandasAtSetInt:
"""
Sets a Python int data in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),),
"data": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str,
data: int) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
data: int (int): The value to set in the cell.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
dataframe.at[row_index, column_label] = data
return (dataframe,)
@@ -0,0 +1,61 @@
from typing import Any, Dict
import pandas as pd
class PandasAtSetString:
"""
Sets a Python string data in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),),
"data": ("STRING", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str,
data: str) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
data: string (str): The value to set in the cell.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
dataframe.at[row_index, column_label] = data
return (dataframe,)
@@ -0,0 +1,56 @@
from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasAtString:
"""
Selects a cell from a pandas DataFrame and output as a string.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_index": ("STRING", {"default": ""}),
"row_index_type":(("string", "int"),),
"column_label": ("STRING", {"default": ""}),
"column_label_type":(("string", "int"),)
}
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,
column_label_type: str) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_index (str): The row index (row label) for the cell.
row_index_type (str): The data type of the row index.
column_label (str): The column label for the cell.
column_label_type (str): The data type of the column label.
Returns:
tuple: A tuple containing the value of the cell in string.
"""
row_index = int(row_index) if row_index_type == "int" else row_index
column_label = int(column_label) if column_label_type == "int" else column_label
value = dataframe.at[row_index, column_label]
return (value,)
@@ -0,0 +1,48 @@
from typing import Any, Dict
import pandas as pd
import datetime
class PandasIatDatetime:
"""
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("PYDATETIME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
Returns:
tuple: A tuple containing the value of the cell.
"""
value = dataframe.iat[row_integer_position, column_integer_position]
return (value.to_pydatetime(),)
@@ -0,0 +1,46 @@
from typing import Any, Dict
import pandas as pd
class PandasIatFloat:
"""
Selects a cell from a pandas DataFrame and output as a Python float.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("FLOAT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
Returns:
tuple: A tuple containing the value of the cell.
"""
value = dataframe.iat[row_integer_position, column_integer_position]
return (float(value),)
+47
View File
@@ -0,0 +1,47 @@
from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasIatInt:
"""
Selects a cell from a pandas DataFrame and output as a Python int.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("INT",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
Returns:
tuple: A tuple containing the value of the cell.
"""
value = dataframe.iat[row_integer_position, column_integer_position]
return (int(value),)
@@ -0,0 +1,52 @@
from typing import Any, Dict
import pandas as pd
import datetime
class PandasIatSetDatetime:
"""
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"data": ("PYDATETIME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int,
data: datetime.datetime) -> tuple:
"""
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
data: datetime.datetime (datetime.datetime): The value to set in the cell.
Returns:
tuple: A tuple containing the updated DataFrame.
"""
dataframe.iat[row_integer_position, column_integer_position] = data
return (dataframe,)
@@ -0,0 +1,52 @@
from typing import Any, Dict
import pandas as pd
class PandasIatSetFloat:
"""
Sets a Python float data in a cell from a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"data": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int,
data: float) -> tuple:
"""
Sets a Python float data in a cell in a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
data (float): The value to set in the cell.
Returns:
tuple: A tuple containing the updated DataFrame.
"""
dataframe.iat[row_integer_position, column_integer_position] = data
return (dataframe,)
@@ -0,0 +1,52 @@
from typing import Any, Dict
import pandas as pd
class PandasIatSetInt:
"""
Sets a Python int data in a cell from a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"data": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int,
data: int) -> tuple:
"""
Sets a Python int data in a cell in a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
data (int): The value to set in the cell.
Returns:
tuple: A tuple containing the updated DataFrame.
"""
dataframe.iat[row_integer_position, column_integer_position] = data
return (dataframe,)
@@ -0,0 +1,52 @@
from typing import Any, Dict
import pandas as pd
import datetime
class PandasIatSetString:
"""
Sets a Python string in a cell in a pandas DataFrame.
This modifies the input DataFrame in place.
category: Transformation
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"data": ("STRING", {"default": ""})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int,
data: str) -> tuple:
"""
Sets a Python string data in a cell in a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
data: string (str): The value to set in the cell.
Returns:
tuple: A tuple containing the updated DataFrame.
"""
dataframe.iat[row_integer_position, column_integer_position] = data
return (dataframe,)
@@ -0,0 +1,47 @@
from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasIatString:
"""
Selects a cell from a pandas DataFrame and output as a string.
category: Data subset selection
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the `cell` function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {}),
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
}
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame,
row_integer_position: int,
column_integer_position: int) -> tuple:
"""
Selects specific cell from a pandas DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
row_integer_position (int): The row integer position for the cell.
column_integer_position (int): The row integer position for the cell.
Returns:
tuple: A tuple containing the value of the cell.
"""
value = dataframe.iat[row_integer_position, column_integer_position]
return (value,)
@@ -2,7 +2,7 @@ from typing import Any, Dict
from io import StringIO
import pandas as pd
class PandasLocCellStr:
class PandasLocCellString:
"""
Selects a cell from a pandas DataFrame and output as a string.
@@ -28,10 +28,10 @@ class PandasLocCellStr:
}
RETURN_TYPES: tuple = ("STRING",)
FUNCTION: str = "cell"
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def cell(self, dataframe: pd.DataFrame,
def f(self, dataframe: pd.DataFrame,
row_index: str,
row_index_type: str,
column_label: str,