Added Pandas Cov and Corr nodes

This commit is contained in:
HowToSD
2025-02-21 20:46:14 -08:00
parent f18945b4a0
commit c411d95431
7 changed files with 125 additions and 1 deletions
+6
View File
@@ -18,8 +18,10 @@ from .modules.pandas_wrapper.pandas_as_float import PandasAsFloat
from .modules.pandas_wrapper.pandas_as_int import PandasAsInt
from .modules.pandas_wrapper.pandas_as_string import PandasAsString
from .modules.pandas_wrapper.pandas_columns import PandasColumns
from .modules.pandas_wrapper.pandas_corr import PandasCorr
from .modules.pandas_wrapper.pandas_cos import PandasCos
from .modules.pandas_wrapper.pandas_count import PandasCount
from .modules.pandas_wrapper.pandas_cov import PandasCov
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
@@ -123,8 +125,10 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
"PandasAsInt": PandasAsInt,
"PandasAsString": PandasAsString,
"PandasColumns": PandasColumns,
"PandasCorr": PandasCorr,
"PandasCos": PandasCos,
"PandasCount": PandasCount,
"PandasCov": PandasCov,
"PandasCreate": PandasCreate,
"PandasCreateWithIndex": PandasCreateWithIndex,
"PandasCummax": PandasCummax,
@@ -228,8 +232,10 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
"PandasAsInt": "Pandas As Int",
"PandasAsString": "Pandas As String",
"PandasColumns": "Pandas Columns",
"PandasCorr": "Pandas Corr",
"PandasCos": "Pandas Cos",
"PandasCount": "Pandas Count",
"PandasCov": "Pandas Cov",
"PandasCreate": "Pandas Create",
"PandasCreateWithIndex": "Pandas Create With Index",
"PandasCummax": "Pandas Cummax",
+2
View File
@@ -111,7 +111,9 @@
## Summary statistics
| Node | Description |
| --- | --- |
| [Pandas Corr](pandas_corr.md) | Computes the correlation of the DataFrame. You can select from the Pearson, Kendall or Spearman methods. |
| [Pandas Count](pandas_count.md) | Computes the count of a pandas DataFrame. |
| [Pandas Cov](pandas_cov.md) | Computes the covariance of the DataFrame. |
| [Pandas Max](pandas_max.md) | Computes the max of a pandas DataFrame. |
| [Pandas Mean](pandas_mean.md) | Computes the mean of a pandas DataFrame. |
| [Pandas Median](pandas_median.md) | Computes the median of a pandas DataFrame. |
+18
View File
@@ -0,0 +1,18 @@
# Pandas Corr
Computes the correlation of the DataFrame. You can select from the Pearson, Kendall or Spearman methods.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
| method | |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Summary statistics
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+17
View File
@@ -0,0 +1,17 @@
# Pandas Cov
Computes the covariance of the DataFrame.
## Input
| Name | Data type |
|---|---|
| dataframe | DataFrame |
## Output
| Data type |
|---|
| DataFrame |
<HR>
Category: Summary statistics
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
+41
View File
@@ -0,0 +1,41 @@
from typing import Any, Dict
import pandas as pd
class PandasCorr:
"""
Computes the correlation of the DataFrame. You can select from the Pearson, Kendall or Spearman methods.
category: Summary statistics
"""
@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", {}),
"method": (("pearson", "kendall", "spearman"),)
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame, method: str) -> tuple:
"""
Computes the correlation of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the result.
"""
return (dataframe.corr(method),)
+40
View File
@@ -0,0 +1,40 @@
from typing import Any, Dict
import pandas as pd
class PandasCov:
"""
Computes the covariance of the DataFrame.
category: Summary statistics
"""
@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", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Computes the covariance of the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the result.
"""
return (dataframe.cov(),)
+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.18"
version = "1.1.19"
license = {file = "LICENSE"}
[project.urls]