Added Pandas Series To DataFrame and Pandas Transpose nodes.
This commit is contained in:
@@ -59,6 +59,7 @@ from .modules.pandas_wrapper.pandas_save_json import PandasSaveJSON
|
||||
from .modules.pandas_wrapper.pandas_select_columns import PandasSelectColumns
|
||||
from .modules.pandas_wrapper.pandas_select_rows import PandasSelectRows
|
||||
from .modules.pandas_wrapper.pandas_series_to_string import PandasSeriesToString
|
||||
from .modules.pandas_wrapper.pandas_series_to_dataframe import PandasSeriesToDataFrame
|
||||
from .modules.pandas_wrapper.pandas_show_dataframe import PandasShowDataFrame
|
||||
from .modules.pandas_wrapper.pandas_show_index import PandasShowIndex
|
||||
from .modules.pandas_wrapper.pandas_show_series import PandasShowSeries
|
||||
@@ -70,6 +71,7 @@ from .modules.pandas_wrapper.pandas_sub_series import PandasSubSeries
|
||||
from .modules.pandas_wrapper.pandas_sum import PandasSum
|
||||
from .modules.pandas_wrapper.pandas_summary import PandasSummary
|
||||
from .modules.pandas_wrapper.pandas_to_string import PandasToString
|
||||
from .modules.pandas_wrapper.pandas_transpose import PandasTranspose
|
||||
from .modules.pandas_wrapper.pandas_var import PandasVar
|
||||
from .modules.pandas_wrapper.pandas_vertical_concat import PandasVerticalConcat
|
||||
from .modules.pandas_wrapper.pandas_vertical_split import PandasVerticalSplit
|
||||
@@ -137,6 +139,7 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasSelectColumns": PandasSelectColumns,
|
||||
"PandasSelectRows": PandasSelectRows,
|
||||
"PandasSeriesToString": PandasSeriesToString,
|
||||
"PandasSeriesToDataFrame": PandasSeriesToDataFrame,
|
||||
"PandasShowDataFrame": PandasShowDataFrame,
|
||||
"PandasShowIndex": PandasShowIndex,
|
||||
"PandasShowSeries": PandasShowSeries,
|
||||
@@ -148,6 +151,7 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasSum": PandasSum,
|
||||
"PandasSummary": PandasSummary,
|
||||
"PandasToString": PandasToString,
|
||||
"PandasTranspose": PandasTranspose,
|
||||
"PandasVar": PandasVar,
|
||||
"PandasVerticalConcat": PandasVerticalConcat,
|
||||
"PandasVerticalSplit": PandasVerticalSplit
|
||||
@@ -218,6 +222,7 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasSelectColumns": "Pandas Select Columns",
|
||||
"PandasSelectRows": "Pandas Select Rows",
|
||||
"PandasSeriesToString": "Pandas Series To String",
|
||||
"PandasSeriesToDataFrame": "Pandas Series To DataFrame",
|
||||
"PandasShowDataFrame": "Pandas Show DataFrame",
|
||||
"PandasShowIndex": "Pandas Show Index",
|
||||
"PandasShowSeries": "Pandas Show Series",
|
||||
@@ -229,6 +234,7 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasSum": "Pandas Sum",
|
||||
"PandasSummary": "Pandas Summary",
|
||||
"PandasToString": "Pandas To String",
|
||||
"PandasTranspose": "Pandas Transpose",
|
||||
"PandasVar": "Pandas Var",
|
||||
"PandasVerticalConcat": "Pandas Vertical Concat",
|
||||
"PandasVerticalSplit": "Pandas Vertical Split"
|
||||
|
||||
@@ -106,6 +106,8 @@
|
||||
| [Pandas Horizontal Split](pandas_horizontal_split.md) | Horizontally splits a Pandas DataFrame into two pandas DataFrames. |
|
||||
| [Pandas Join](pandas_join.md) | Merges two pandas DataFrames based on a common column. |
|
||||
| [Pandas Rename](pandas_rename.md) | Renames an index (row label) or a column label. |
|
||||
| [Pandas Series To Data Frame](pandas_series_to_dataframe.md) | Converts a Pandas Series to a DataFrame. |
|
||||
| [Pandas Sort](pandas_sort.md) | Sorts a pandas DataFrame by a specified column. |
|
||||
| [Pandas Transpose](pandas_transpose.md) | Transposes a DataFrame. |
|
||||
| [Pandas Vertical Concat](pandas_vertical_concat.md) | Vertically concatenates two pandas DataFrames. |
|
||||
| [Pandas Vertical Split](pandas_vertical_split.md) | Vertically splits a Pandas DataFrame into two pandas DataFrames. |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Pandas Rename
|
||||
Renames an index (row label) or a column label.
|
||||
|
||||
Currently, renaming only works for string labels. Renaming of integer labels is not supported.
|
||||
Note below node parameter description is incomplete due to a reference generator's bug:
|
||||
* axis takes columns or index.
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pandas Series To Data Frame
|
||||
Converts a Pandas Series to a DataFrame.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| series | Series |
|
||||
| label | String |
|
||||
| transpose | Boolean |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Pandas Transpose
|
||||
Transposes a DataFrame.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -5,7 +5,7 @@ import pandas as pd
|
||||
class PandasRename:
|
||||
"""
|
||||
Renames an index (row label) or a column label.
|
||||
|
||||
Currently, renaming only works for string labels. Renaming of integer labels is not supported.
|
||||
Note below node parameter description is incomplete due to a reference generator's bug:
|
||||
* axis takes columns or index.
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasSeriesToDataFrame:
|
||||
"""
|
||||
Converts a Pandas Series to a DataFrame.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"series": ("PDSERIES", {}),
|
||||
"label": ("STRING", {"default": ""}),
|
||||
"transpose": ("BOOLEAN", {"default": True})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, series: pd.Series, label: str, transpose: bool) -> tuple:
|
||||
"""
|
||||
Converts a Pandas Series to a DataFrame.
|
||||
|
||||
Args:
|
||||
series (Series): The Series.
|
||||
label (str): The label for the Series in the DataFrame.
|
||||
transpose (bool): Whether to transpose the DataFrame after conversion.
|
||||
If True, Series will become a row. Otherwise it will become a column.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
df = series.to_frame(name=label) if label else series.to_frame()
|
||||
df = df.transpose() if transpose else df
|
||||
return (df,)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasTranspose:
|
||||
"""
|
||||
Transposes a DataFrame.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@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:
|
||||
"""
|
||||
Transposes a DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the transposed DataFrame.
|
||||
"""
|
||||
return (dataframe.transpose(),)
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "data-analysis"
|
||||
description = "Data analysis custom modules for ComfyUI - Use Pandas & Matplotlib within ComfyUI"
|
||||
version = "1.1.9"
|
||||
version = "1.1.10"
|
||||
license = {file = "LICENSE"}
|
||||
|
||||
[project.urls]
|
||||
|
||||
Reference in New Issue
Block a user