Added Pandas Cummax, Cummin, Cumprod, Cumsum nodes.

This commit is contained in:
HowToSD
2025-02-20 07:46:43 -08:00
parent c076e42c15
commit 731436837f
11 changed files with 284 additions and 1 deletions
+12
View File
@@ -18,6 +18,10 @@ from .modules.pandas_wrapper.pandas_columns import PandasColumns
from .modules.pandas_wrapper.pandas_count import PandasCount
from .modules.pandas_wrapper.pandas_create import PandasCreate
from .modules.pandas_wrapper.pandas_create_with_index import PandasCreateWithIndex
from .modules.pandas_wrapper.pandas_cummax import PandasCummax
from .modules.pandas_wrapper.pandas_cummin import PandasCummin
from .modules.pandas_wrapper.pandas_cumprod import PandasCumprod
from .modules.pandas_wrapper.pandas_cumsum import PandasCumsum
from .modules.pandas_wrapper.pandas_div import PandasDiv
from .modules.pandas_wrapper.pandas_div_series import PandasDivSeries
from .modules.pandas_wrapper.pandas_dropna import PandasDropNA
@@ -98,6 +102,10 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
"PandasCount": PandasCount,
"PandasCreate": PandasCreate,
"PandasCreateWithIndex": PandasCreateWithIndex,
"PandasCummax": PandasCummax,
"PandasCummin": PandasCummin,
"PandasCumprod": PandasCumprod,
"PandasCumsum": PandasCumsum,
"PandasDiv": PandasDiv,
"PandasDivSeries": PandasDivSeries,
"PandasDropNA": PandasDropNA,
@@ -181,6 +189,10 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
"PandasCount": "Pandas Count",
"PandasCreate": "Pandas Create",
"PandasCreateWithIndex": "Pandas Create With Index",
"PandasCummax": "Pandas Cummax",
"PandasCummin": "Pandas Cummin",
"PandasCumprod": "Pandas Cumprod",
"PandasCumsum": "Pandas Cumsum",
"PandasDiv": "Pandas Div",
"PandasDivSeries": "Pandas Div Series",
"PandasDropNA": "Pandas Drop NA",
+7
View File
@@ -16,6 +16,13 @@
| [Pandas Pow Series](pandas_pow_series.md) | Raises a Pandas DataFrame to the power of a Pandas Series. |
| [Pandas Sub](pandas_sub.md) | Subtracts a Pandas DataFrame from another DataFrame. |
| [Pandas Sub Series](pandas_sub_series.md) | Subtracts a Pandas Series from a Pandas DataFrame. |
## Cumulative calculations
| Node | Description |
| --- | --- |
| [Pandas Cummax](pandas_cummax.md) | Computes the cummax (cumulative max) of the DataFrame. |
| [Pandas Cummin](pandas_cummin.md) | Computes the cummin (cumulative minimum) of the DataFrame. |
| [Pandas Cumprod](pandas_cumprod.md) | Computes the cumprod (cumulative product) of the DataFrame. |
| [Pandas Cumsum](pandas_cumsum.md) | Computes the cumsum (cumulative sum) of the DataFrame. |
## Data cleansing
| Node | Description |
| --- | --- |
+18
View File
@@ -0,0 +1,18 @@
# Pandas Cummax
Computes the cummax (cumulative max) of the DataFrame.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
| axis | |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Cumulative calculations
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+18
View File
@@ -0,0 +1,18 @@
# Pandas Cummin
Computes the cummin (cumulative minimum) of the DataFrame.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
| axis | |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Cumulative calculations
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+18
View File
@@ -0,0 +1,18 @@
# Pandas Cumprod
Computes the cumprod (cumulative product) of the DataFrame.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
| axis | |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Cumulative calculations
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+18
View File
@@ -0,0 +1,18 @@
# Pandas Cumsum
Computes the cumsum (cumulative sum) of the DataFrame.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
| axis | |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Cumulative calculations
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+48
View File
@@ -0,0 +1,48 @@
from typing import Any, Dict
import pandas as pd
class PandasCummax:
"""
Computes the cummax (cumulative max) of the DataFrame.
category: Cumulative calculations
"""
@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", {}),
"axis": (("index", "columns"),),
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
"""
Computes the cummax (cumulative max) of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
axis (str): Specify the direction to compute: Index (row label) or column label.
Returns:
tuple: A tuple containing a JSON string of the renamed DataFrame.
"""
if axis=="index":
df_out = dataframe.cummax(axis=0)
elif axis=="columns":
df_out = dataframe.cummax(axis=1)
else:
raise ValueError("Invalid axis. Only index or columns are supported.")
return (df_out,)
+48
View File
@@ -0,0 +1,48 @@
from typing import Any, Dict
import pandas as pd
class PandasCummin:
"""
Computes the cummin (cumulative minimum) of the DataFrame.
category: Cumulative calculations
"""
@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", {}),
"axis": (("index", "columns"),),
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
"""
Computes the cummin (cumulative minimum) of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
axis (str): Specify the direction to compute: Index (row label) or column label.
Returns:
tuple: A tuple containing a JSON string of the renamed DataFrame.
"""
if axis=="index":
df_out = dataframe.cummin(axis=0)
elif axis=="columns":
df_out = dataframe.cummin(axis=1)
else:
raise ValueError("Invalid axis. Only index or columns are supported.")
return (df_out,)
+48
View File
@@ -0,0 +1,48 @@
from typing import Any, Dict
import pandas as pd
class PandasCumprod:
"""
Computes the cumprod (cumulative product) of the DataFrame.
category: Cumulative calculations
"""
@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", {}),
"axis": (("index", "columns"),),
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
"""
Computes the cumprod (cumulative product) of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
axis (str): Specify the direction to compute: Index (row label) or column label.
Returns:
tuple: A tuple containing a JSON string of the renamed DataFrame.
"""
if axis=="index":
df_out = dataframe.cumprod(axis=0)
elif axis=="columns":
df_out = dataframe.cumprod(axis=1)
else:
raise ValueError("Invalid axis. Only index or columns are supported.")
return (df_out,)
+48
View File
@@ -0,0 +1,48 @@
from typing import Any, Dict
import pandas as pd
class PandasCumsum:
"""
Computes the cumsum (cumulative sum) of the DataFrame.
category: Cumulative calculations
"""
@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", {}),
"axis": (("index", "columns"),),
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
"""
Computes the cumsum (cumulative sum) of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
axis (str): Specify the direction to compute: Index (row label) or column label.
Returns:
tuple: A tuple containing a JSON string of the renamed DataFrame.
"""
if axis=="index":
df_out = dataframe.cumsum(axis=0)
elif axis=="columns":
df_out = dataframe.cumsum(axis=1)
else:
raise ValueError("Invalid axis. Only index or columns are supported.")
return (df_out,)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "data-analysis"
description = "Data analysis custom modules for ComfyUI - Use Pandas & Matplotlib within ComfyUI"
version = "1.1.10"
version = "1.1.11"
license = {file = "LICENSE"}
[project.urls]