Added more logical operations nodes to handle scalar comparison.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, Dict
|
||||
import ast
|
||||
|
||||
class PyStringToList:
|
||||
@@ -9,12 +9,12 @@ class PyStringToList:
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> List[str]:
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
List[str, Any]: A list specifying required input types.
|
||||
Dict[str, Any]: A list specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasBooleanIndex:
|
||||
"""
|
||||
Selects rows from a pandas DataFrame based on the boolean index in the Series.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"boolean_index_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame, boolean_index_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Selects rows from a pandas DataFrame based on the boolean index in the Series.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
boolean_index_series: (pd.Series): The Series containing boolean index.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the filtered DataFrame.
|
||||
"""
|
||||
if not isinstance(boolean_index_series, pd.Series):
|
||||
raise ValueError("boolean_index_series is not a Series.")
|
||||
|
||||
df2 = dataframe[boolean_index_series]
|
||||
return (df2,)
|
||||
@@ -0,0 +1,49 @@
|
||||
from typing import List, Any, Tuple, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasCreateSeriesFromList:
|
||||
"""
|
||||
Creates a Pandas Series from a Python list.
|
||||
|
||||
category: IO
|
||||
"""
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"data": ("PYLIST", {}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: List[Any]) -> Tuple[pd.Series]:
|
||||
"""
|
||||
Creates a Pandas Series from a Python list.
|
||||
|
||||
Args:
|
||||
data (List[Any]): A list with cell values.
|
||||
|
||||
Returns:
|
||||
Tuple[pd.Series]: A tuple containing a Pandas Series.
|
||||
|
||||
Raises:
|
||||
ValueError: If the data is not a list.
|
||||
"""
|
||||
if not isinstance(data, list):
|
||||
raise ValueError("Input must be a list.")
|
||||
|
||||
if len(data) == 0:
|
||||
return (pd.Series(),)
|
||||
else:
|
||||
return (pd.Series(data),)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
from typing import List, Any, Tuple, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasCreateSeriesFromListIndexList:
|
||||
"""
|
||||
Creates a Pandas Series from a Python list of cell values and a list for index.
|
||||
|
||||
category: IO
|
||||
"""
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"data": ("PYLIST", {}),
|
||||
"index": ("PYLIST", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: List[Any], index: List[Any]) -> Tuple[pd.Series]:
|
||||
"""
|
||||
Creates a Pandas Series from a Python list of cell values and a list for index.
|
||||
|
||||
Args:
|
||||
data (List[Any]): A list with cell values.
|
||||
index (List): A Python list containing index.
|
||||
|
||||
Returns:
|
||||
Tuple[pd.Series]: A tuple containing a Pandas Series.
|
||||
|
||||
Raises:
|
||||
ValueError: If the data is not a list.
|
||||
"""
|
||||
if not isinstance(data, list):
|
||||
raise ValueError("Input must be a list.")
|
||||
|
||||
if len(data) == 0:
|
||||
return (pd.Series(),)
|
||||
else:
|
||||
return (pd.Series(data, index=index),)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasEqScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is equal to the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.eq(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasEqScalarInt:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is equal to the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.eq(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasGeScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.ge(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasGeScalarInt:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the int.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: int) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the int.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (int): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.ge(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasGtScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the first pandas DataFrame is greater than the corresponding element in the second DataFrame.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.gt(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasGtScalarInt:
|
||||
"""
|
||||
Determines whether each element in the first pandas DataFrame is greater than the corresponding element in the second DataFrame.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: int) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is greater than or equal to the int.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (int): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.gt(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasLeScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than or equal to the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than or equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.le(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,45 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasLeScalarInt:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than or equal to the int.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: int) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than or equal to the int.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (int): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.le(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasLtScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.lt(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,45 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasLtScalarInt:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than the int.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: int) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is less than the int.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (int): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.lt(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasNeScalarFloat:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is not equal to the float.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: float) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is not equal to the float.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (float): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.ne(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasNeScalarInt:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is not equal to the int.
|
||||
|
||||
category: Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"number": ("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, number: int) -> tuple:
|
||||
"""
|
||||
Determines whether each element in the pandas DataFrame is not equal to the int.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
number (int): The number.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of operation.
|
||||
"""
|
||||
df_out = dataframe.ne(number)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
from .utils import column_labels_string_to_list
|
||||
|
||||
class PandasSelectColumnAsSeries:
|
||||
"""
|
||||
Selects specific column as Series from a pandas DataFrame.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"column_name": ("STRING", {"default": ""})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame, column_name: str) -> tuple:
|
||||
"""
|
||||
Selects specific column as Series from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
column_name (str): A column name to select.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the Series with selected column.
|
||||
"""
|
||||
series = dataframe[column_name]
|
||||
return (series,)
|
||||
Reference in New Issue
Block a user