Major refactoring to pass DataFrame object without serializing. Almost all nodes were modified for this. Binary operator nodes were added as well.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
# ComfyUI-Data-Analysis
|
||||
## Update
|
||||
v1.1.0 was released which contains backward incompatible changes for worklows created using the prior version of ComfyUI Data Analysis custom nodes. Please read the Release Note.
|
||||
|
||||

|
||||
## How Can We Figure Out Which MLB Player Had the Most Hits Per Year?
|
||||
|
||||
|
||||
+45
@@ -3,16 +3,24 @@ from .modules.cda.cda_json_create import CDAJSONCreate
|
||||
from .modules.matplotlib.mpl_bar import MPLBar
|
||||
from .modules.matplotlib.mpl_line import MPLLine
|
||||
from .modules.matplotlib.mpl_scatter import MPLScatter
|
||||
from .modules.pandas_wrapper.pandas_add import PandasAdd
|
||||
from .modules.pandas_wrapper.pandas_add_series import PandasAddSeries
|
||||
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_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_div import PandasDiv
|
||||
from .modules.pandas_wrapper.pandas_div_series import PandasDivSeries
|
||||
from .modules.pandas_wrapper.pandas_dropna import PandasDropNA
|
||||
from .modules.pandas_wrapper.pandas_group_by import PandasGroupBy
|
||||
from .modules.pandas_wrapper.pandas_head import PandasHead
|
||||
from .modules.pandas_wrapper.pandas_iloc_row_series import PandasIlocRowSeries
|
||||
from .modules.pandas_wrapper.pandas_iloc_rows_dataframe import PandasIlocRowsDataFrame
|
||||
from .modules.pandas_wrapper.pandas_index import PandasIndex
|
||||
from .modules.pandas_wrapper.pandas_index_to_string import PandasIndexToString
|
||||
from .modules.pandas_wrapper.pandas_isna import PandasIsNA
|
||||
from .modules.pandas_wrapper.pandas_join import PandasJoin
|
||||
from .modules.pandas_wrapper.pandas_load_csv import PandasLoadCSV
|
||||
@@ -26,16 +34,23 @@ from .modules.pandas_wrapper.pandas_mean import PandasMean
|
||||
from .modules.pandas_wrapper.pandas_median import PandasMedian
|
||||
from .modules.pandas_wrapper.pandas_min import PandasMin
|
||||
from .modules.pandas_wrapper.pandas_mode import PandasMode
|
||||
from .modules.pandas_wrapper.pandas_mul import PandasMul
|
||||
from .modules.pandas_wrapper.pandas_mul_series import PandasMulSeries
|
||||
from .modules.pandas_wrapper.pandas_pow import PandasPow
|
||||
from .modules.pandas_wrapper.pandas_pow_series import PandasPowSeries
|
||||
from .modules.pandas_wrapper.pandas_save_csv import PandasSaveCSV
|
||||
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_show_dataframe import PandasShowDataFrame
|
||||
from .modules.pandas_wrapper.pandas_show_index import PandasShowIndex
|
||||
from .modules.pandas_wrapper.pandas_show_series import PandasShowSeries
|
||||
from .modules.pandas_wrapper.pandas_show_text import PandasShowText
|
||||
from .modules.pandas_wrapper.pandas_sort import PandasSort
|
||||
from .modules.pandas_wrapper.pandas_std import PandasStd
|
||||
from .modules.pandas_wrapper.pandas_sub import PandasSub
|
||||
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
|
||||
@@ -49,16 +64,24 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"MPLBar": MPLBar,
|
||||
"MPLLine": MPLLine,
|
||||
"MPLScatter": MPLScatter,
|
||||
"PandasAdd": PandasAdd,
|
||||
"PandasAddSeries": PandasAddSeries,
|
||||
"PandasAsFloat": PandasAsFloat,
|
||||
"PandasAsInt": PandasAsInt,
|
||||
"PandasAsString": PandasAsString,
|
||||
"PandasColumns": PandasColumns,
|
||||
"PandasCount": PandasCount,
|
||||
"PandasCreate": PandasCreate,
|
||||
"PandasCreateWithIndex": PandasCreateWithIndex,
|
||||
"PandasDiv": PandasDiv,
|
||||
"PandasDivSeries": PandasDivSeries,
|
||||
"PandasDropNA": PandasDropNA,
|
||||
"PandasGroupBy": PandasGroupBy,
|
||||
"PandasHead": PandasHead,
|
||||
"PandasIlocRowSeries": PandasIlocRowSeries,
|
||||
"PandasIlocRowsDataFrame": PandasIlocRowsDataFrame,
|
||||
"PandasIndex": PandasIndex,
|
||||
"PandasIndexToString": PandasIndexToString,
|
||||
"PandasIsNA": PandasIsNA,
|
||||
"PandasJoin": PandasJoin,
|
||||
"PandasLoadCSV": PandasLoadCSV,
|
||||
@@ -72,16 +95,23 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasMedian": PandasMedian,
|
||||
"PandasMin": PandasMin,
|
||||
"PandasMode": PandasMode,
|
||||
"PandasMul": PandasMul,
|
||||
"PandasMulSeries": PandasMulSeries,
|
||||
"PandasPow": PandasPow,
|
||||
"PandasPowSeries": PandasPowSeries,
|
||||
"PandasSaveCSV": PandasSaveCSV,
|
||||
"PandasSaveJSON": PandasSaveJSON,
|
||||
"PandasSelectColumns": PandasSelectColumns,
|
||||
"PandasSelectRows": PandasSelectRows,
|
||||
"PandasSeriesToString": PandasSeriesToString,
|
||||
"PandasShowDataFrame": PandasShowDataFrame,
|
||||
"PandasShowIndex": PandasShowIndex,
|
||||
"PandasShowSeries": PandasShowSeries,
|
||||
"PandasShowText": PandasShowText,
|
||||
"PandasSort": PandasSort,
|
||||
"PandasStd": PandasStd,
|
||||
"PandasSub": PandasSub,
|
||||
"PandasSubSeries": PandasSubSeries,
|
||||
"PandasSum": PandasSum,
|
||||
"PandasSummary": PandasSummary,
|
||||
"PandasToString": PandasToString,
|
||||
@@ -97,16 +127,24 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"MPLBar": "MPL Bar Chart",
|
||||
"MPLLine": "MPL Line Plot",
|
||||
"MPLScatter": "MPL Scatter Plot",
|
||||
"PandasAdd": "Pandas Add",
|
||||
"PandasAddSeries": "Pandas Add Series",
|
||||
"PandasAsFloat": "Pandas As Float",
|
||||
"PandasAsInt": "Pandas As Int",
|
||||
"PandasAsString": "Pandas As String",
|
||||
"PandasColumns": "Pandas Columns",
|
||||
"PandasCount": "Pandas Count",
|
||||
"PandasCreate": "Pandas Create",
|
||||
"PandasCreateWithIndex": "Pandas Create With Index",
|
||||
"PandasDiv": "Pandas Div",
|
||||
"PandasDivSeries": "Pandas Div Series",
|
||||
"PandasDropNA": "Pandas Drop NA",
|
||||
"PandasGroupBy": "Pandas Group By",
|
||||
"PandasHead": "Pandas Head",
|
||||
"PandasIlocRowSeries": "Pandas Iloc Row Series",
|
||||
"PandasIlocRowsDataFrame": "Pandas Iloc Rows DataFrame",
|
||||
"PandasIndex": "Pandas Index",
|
||||
"PandasIndexToString": "Pandas Index To String",
|
||||
"PandasIsNA": "Pandas Is NA",
|
||||
"PandasJoin": "Pandas Join",
|
||||
"PandasLoadCSV": "Pandas Load CSV",
|
||||
@@ -120,16 +158,23 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasMedian": "Pandas Median",
|
||||
"PandasMin": "Pandas Min",
|
||||
"PandasMode": "Pandas Mode",
|
||||
"PandasMul": "Pandas Mul",
|
||||
"PandasMulSeries": "Pandas Mul Series",
|
||||
"PandasPow": "Pandas Pow",
|
||||
"PandasPowSeries": "Pandas Pow Series",
|
||||
"PandasSaveCSV": "Pandas Save CSV",
|
||||
"PandasSaveJSON": "Pandas Save JSON",
|
||||
"PandasSelectColumns": "Pandas Select Columns",
|
||||
"PandasSelectRows": "Pandas Select Rows",
|
||||
"PandasSeriesToString": "Pandas Series To String",
|
||||
"PandasShowDataFrame": "Pandas Show DataFrame",
|
||||
"PandasShowIndex": "Pandas Show Index",
|
||||
"PandasShowSeries": "Pandas Show Series",
|
||||
"PandasShowText": "Pandas Show Text",
|
||||
"PandasSort": "Pandas Sort",
|
||||
"PandasStd": "Pandas Std",
|
||||
"PandasSub": "Pandas Sub",
|
||||
"PandasSubSeries": "Pandas Sub Series",
|
||||
"PandasSum": "Pandas Sum",
|
||||
"PandasSummary": "Pandas Summary",
|
||||
"PandasToString": "Pandas To String",
|
||||
|
||||
@@ -5,6 +5,9 @@ The objective is to determine which Major League Baseball player has the most hi
|
||||
|
||||
Fortunately, the [Lahman Baseball Database](http://seanlahman.com/) contains the necessary data, and CDA simplifies the extraction process. Let's dive in.
|
||||
|
||||
**Note**
|
||||
This tutorial was created using an older version of ComfyUI Data Analysis, so screenshots contain the names of deprecated nodes. Use the node name in text if there is any mismatch between text and screenshots.
|
||||
|
||||
# Obtaining data
|
||||
Our first step is to obtain data.
|
||||
1. Access http://seanlahman.com/.
|
||||
@@ -62,7 +65,7 @@ If you see the screenshots, you can see that People data has more than 21000 row
|
||||
|
||||
First we want to extract the names from People data. The reason for this is that Batting table contains the ID of the player and not the full name. So we need names defined in the People table. But how do we do this? If we take a look at the screenshot, you do not see full name columns. It looks like the column names are hidden. So we need to first figure out what columns are avaialbe in the People table.
|
||||
To do so, add a new node **Pandas Columns** and connect it to Load CSV for People.
|
||||
Then add another node **Pandas Show Text** and connect it to the Pandas Columns node. Press Queue, you should see below.
|
||||
Then add another node **Pandas Show Index** and connect it to the Pandas Columns node. Press Queue, you should see below.
|
||||
|
||||

|
||||
|
||||
@@ -131,12 +134,12 @@ In this final section, we will be fixing the name issue where the names are IDs
|
||||

|
||||
|
||||
Drag it next to the **Select Colums** node of the Batting table.
|
||||
Connect the output of the Head node to the "left_dataframe_json" input of the join node.
|
||||
Connect the output of the Head node to the "left_dataframe" input of the join node.
|
||||
|
||||
2. Connect to the People table
|
||||
|
||||
Now drag the join node so that it sits next to the **Select Colums** node of the People table.
|
||||
Connect the output of the Select Columns node to the "right_dataframe_json" input of the join node. Note that you may need to hover your mouse around the top-left corner of the blank area that contains "right_dataframe_json" to find the connection point.
|
||||
Connect the output of the Select Columns node to the "right_dataframe" input of the join node. Note that you may need to hover your mouse around the top-left corner of the blank area that contains "right_dataframe" to find the connection point.
|
||||
|
||||

|
||||
|
||||
|
||||
+44
-7
@@ -1,16 +1,14 @@
|
||||
# User's Guide
|
||||
## Basic Concepts
|
||||
### How DataFrames is passed between nodes
|
||||
DataFrames are transmitted as JSON strings. When a DataFrame enters a node, it is reconstructed by deserializing the JSON string. Upon exiting, it is serialized back into a JSON string.
|
||||
|
||||
Pandas's Index object is also processed the same way. For example, Pandas Columns and Pandas Index node return labels in a serialized Index format.
|
||||
|
||||
### How to connect nodes for DataFrame JSON strings
|
||||
To connect the DataFrame JSON string output from one Pandas node to another, move the wire toward the top-left of the text field. You may need to hover around the corner to find the correct connection point.
|
||||
### How to connect nodes for DataFrame
|
||||
To connect the DataFrame output from one Pandas node to another, move the wire toward the top-left of the text field. You may need to hover around the corner to find the correct connection point.
|
||||
|
||||
### How to add a node
|
||||
You can right-click, select **Add Node**, go to **Data Analysis**, and look for the following nodes:
|
||||
|
||||
**Note**
|
||||
This page was initially created using an older version of ComfyUI Data Analysis, so some of screenshots contain the names of deprecated nodes. Use the node name in text if there is any mismatch between text and screenshots.
|
||||
|
||||
### List of nodes
|
||||
**Data loading, creation, saving**
|
||||
| Node Name | Functionality |
|
||||
@@ -50,6 +48,7 @@ You can right-click, select **Add Node**, go to **Data Analysis**, and look for
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Show DataFrame** | Display DataFrame contents |
|
||||
| **Pandas Show Series** | Display Series contents |
|
||||
| **Pandas Show Index** | Display Index contents |
|
||||
| **Pandas Show Text** | Display Text |
|
||||
| **Pandas Summary** | Extract DataFrame statistics |
|
||||
|
||||
@@ -72,9 +71,28 @@ You can right-click, select **Add Node**, go to **Data Analysis**, and look for
|
||||
| **Pandas Sum** | Sum of row values |
|
||||
| **Pandas Var** | Variance of row values |
|
||||
|
||||
**Binary operators for two DataFrames**
|
||||
| Node Name | Functionality |
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Add** | Add two DataFrames |
|
||||
| **Pandas Div** | Divide a DataFrame by another DataFrame |
|
||||
| **Pandas Mul** | Multiply two DataFrames |
|
||||
| **Pandas Pow** | Raise a DataFrame to the power of another DataFrame |
|
||||
| **Pandas Sub** | Subtract a DataFrame from another DataFrame |
|
||||
|
||||
**Binary operators for a DataFrame and a Series**
|
||||
| Node Name | Functionality |
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Add Series** | Add a DataFrame and a Series |
|
||||
| **Pandas Div Series** | Divide a DataFrame by a Series |
|
||||
| **Pandas Mul Series** | Multiply a DataFrame by a Series |
|
||||
| **Pandas Pow Series** | Raise a DataFrame to the power of a Series |
|
||||
| **Pandas Sub Series** | Subtract a Series from another DataFrame |
|
||||
|
||||
**Converting to displayable string**
|
||||
| Node Name | Functionality |
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Index To String** | Convert Index to a displayable string |
|
||||
| **Pandas Series To String** | Convert Series to a displayable string |
|
||||
| **Pandas To String** | Convert DataFrame to a displayable string |
|
||||
|
||||
@@ -245,6 +263,25 @@ coconut
|
||||
```
|
||||
In this case, both apple and coconut are the mode.
|
||||
|
||||
## Binary operators for DataFrames and Series
|
||||
For binary operation for two DataFrames, you can use below operators:
|
||||
| Node Name | Functionality |
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Add** | Add two DataFrames |
|
||||
| **Pandas Div** | Divide a DataFrame by another DataFrame |
|
||||
| **Pandas Mul** | Multiply two DataFrames |
|
||||
| **Pandas Pow** | Raise a DataFrame to the power of another DataFrame |
|
||||
| **Pandas Sub** | Subtract a DataFrame from another DataFrame |
|
||||
|
||||
For binary operation for a DataFrame and a Series, you can use below operators:
|
||||
| Node Name | Functionality |
|
||||
|-------------------------|-------------------------------------|
|
||||
| **Pandas Add Series** | Add a DataFrame and a Series |
|
||||
| **Pandas Div Series** | Divide a DataFrame by a Series |
|
||||
| **Pandas Mul Series** | Multiply a DataFrame by a Series |
|
||||
| **Pandas Pow Series** | Raise a DataFrame to the power of a Series |
|
||||
| **Pandas Sub Series** | Subtract a Series from another DataFrame |
|
||||
|
||||
## Convert DataFrame to a string
|
||||
Use **Pandas To String**. This node is to convert the DataFrame to a displayable string, and this truncates the data when the data is large. This can be used to display the data content in a text display node (e.g. Show Text node). However, you can use Show DataFrame nodes to display the DataFrame content, so you do not normally need to use this.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"last_node_id":4,"last_link_id":2,"nodes":[{"id":1,"type":"PandasCreate","pos":[-326.9039306640625,1636.5106201171875],"size":[210,138.73008728027344],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[1],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n1,10\n2,20\n3,30"]},{"id":4,"type":"PandasShowDataFrame","pos":[-64.19639587402344,1834.85595703125],"size":[217.840576171875,134.7733612060547],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":2,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\nUS 1 10\nFrance 2 20\nGermany 3 30"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-324.8951416015625,1834.365478515625],"size":[210,134.33523559570312],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[2],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,20\nGermany,3,30",0]},{"id":2,"type":"PandasShowDataFrame","pos":[-64.8188705444336,1635.102783203125],"size":[216.83184814453125,135.75343322753906],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":1,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\n0 1 10\n1 2 20\n2 3 30"]}],"links":[[1,1,0,2,0,"STRING"],[2,3,0,4,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.5305009021021516,"offset":[477.1330786503176,-1565.7063254190393]},"node_versions":{"data-analysis":"3e5a6d6efce2f08933edccaf9e1c1e38896df00b"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":4,"last_link_id":4,"nodes":[{"id":4,"type":"PandasShowDataFrame","pos":[-64.19639587402344,1834.85595703125],"size":[217.840576171875,134.7733612060547],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":4}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\nindex \nUS 1 10\nFrance 2 20\nGermany 3 30"]},{"id":2,"type":"PandasShowDataFrame","pos":[-64.8188705444336,1635.102783203125],"size":[216.83184814453125,135.75343322753906],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":3}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\n0 1 10\n1 2 20\n2 3 30"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-324.8951416015625,1834.365478515625],"size":[210,134.33523559570312],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[4],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,20\nGermany,3,30",0]},{"id":1,"type":"PandasCreate","pos":[-326.9039306640625,1636.5106201171875],"size":[210,138.73008728027344],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[3],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n1,10\n2,20\n3,30"]}],"links":[[3,1,0,2,0,"DATAFRAME"],[4,3,0,4,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.662759310116916,"offset":[538.1885155497253,-1531.0150349934897]},"node_versions":{"data-analysis":"d1135d404ccf4f6d523db77b95dff3934f62a384"},"ue_links":[]},"version":0.4}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"last_node_id":2,"last_link_id":1,"nodes":[{"id":1,"type":"PandasLoadCSV","pos":[490.4385070800781,2068.794921875],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[1],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]},{"id":2,"type":"PandasShowDataFrame","pos":[1063.93798828125,2068.40283203125],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":1,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":1,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," Name Price InStock OnSale\n0 fig 4.11 1.0 1\n1 safou 1.24 1.0 0\n2 papaya 5.11 1.0 1\n3 plum 2.53 1.0 1\n4 guava 0.66 1.0 1\n.. ... ... ... ...\n95 black currant 8.15 0.0 1\n96 red currant 7.71 0.0 1\n97 black currant 4.41 1.0 0\n98 red currant 2.18 0.0 0\n99 black currant 0.80 1.0 1\n\n[100 rows x 4 columns]"]}],"links":[[1,1,0,2,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.1498879805425606,"offset":[-454.3122480950786,-1970.7113583389635]},"node_versions":{"ComfyUI-Data-Analysis":"235c84b7b8aafc3c4b904ba8f03c89aade96b640"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":2,"last_link_id":2,"nodes":[{"id":2,"type":"PandasShowDataFrame","pos":[1063.93798828125,2068.40283203125],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":1,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":2}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" Name Price InStock OnSale\n0 fig 4.11 1 1\n1 safou 1.24 1 0\n2 papaya 5.11 1 1\n3 plum 2.53 1 1\n4 guava 0.66 1 1\n.. ... ... ... ...\n95 black currant 8.15 0 1\n96 red currant 7.71 0 1\n97 black currant 4.41 1 0\n98 red currant 2.18 0 0\n99 black currant 0.80 1 1\n\n[100 rows x 4 columns]"]},{"id":1,"type":"PandasLoadCSV","pos":[490.4385070800781,2068.794921875],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[2],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]}],"links":[[2,1,0,2,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.2429202682416007,"offset":[-395.062420203444,-1847.5073301150765]},"node_versions":{"data-analysis":"a12de2f44c180d9136ec09572803a0fc525f7c9a"},"ue_links":[]},"version":0.4}
|
||||
@@ -1 +1 @@
|
||||
{"last_node_id":12,"last_link_id":8,"nodes":[{"id":8,"type":"PandasShowText","pos":[3.62848162651062,1602.7939453125],"size":[210,78.36762237548828],"flags":{},"order":6,"mode":0,"inputs":[{"name":"text","type":"STRING","link":5,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","30"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-607.1369018554688,1436.66015625],"size":[210,136.70285034179688],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[2,4],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,20\nGermany,3,30",0]},{"id":4,"type":"PandasShowDataFrame","pos":[-288.99395751953125,1434.0804443359375],"size":[210,116.62158966064453],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":2,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\nUS 1 10\nFrance 2 20\nGermany 3 30"]},{"id":10,"type":"PandasShowDataFrame","pos":[-293.0326232910156,1839.1920166015625],"size":[210,116.62158966064453],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":7,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\n0 10 100\n1 20 200\n2 30 300"]},{"id":12,"type":"PandasShowText","pos":[8.03433609008789,2006.485107421875],"size":[210,78.36762237548828],"flags":{},"order":7,"mode":0,"inputs":[{"name":"text","type":"STRING","link":6,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","30"]},{"id":11,"type":"PandasLocCellStr","pos":[-291.8468933105469,2007.802734375],"size":[267.4131774902344,156.59359741210938],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":8,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[6],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocCellStr"},"widgets_values":["","2","int","A","string"]},{"id":7,"type":"PandasLocCellStr","pos":[-294.200927734375,1601.82275390625],"size":[267.4131774902344,156.59359741210938],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":4,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[5],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocCellStr"},"widgets_values":["","Germany","string","B","string"]},{"id":9,"type":"PandasCreate","pos":[-610.7672119140625,1838.9556884765625],"size":[210,113.97640228271484],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[7,8],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n10,100\n20,200\n30,300"]}],"links":[[2,3,0,4,0,"STRING"],[4,3,0,7,0,"STRING"],[5,7,0,8,0,"STRING"],[6,11,0,12,0,"STRING"],[7,9,0,10,0,"STRING"],[8,9,0,11,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.863927859160454,"offset":[1091.6818551119054,-1331.0653891577363]},"node_versions":{"data-analysis":"d484a368b2c6ce687911c30d1325c680758e7a24"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":12,"last_link_id":12,"nodes":[{"id":4,"type":"PandasShowDataFrame","pos":[-288.99395751953125,1434.0804443359375],"size":[210,116.62158966064453],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":9}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\nindex \nUS 1 10\nFrance 2 20\nGermany 3 30"]},{"id":10,"type":"PandasShowDataFrame","pos":[-293.0326232910156,1839.1920166015625],"size":[210,116.62158966064453],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":11}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\n0 10 100\n1 20 200\n2 30 300"]},{"id":12,"type":"PandasShowText","pos":[8.03433609008789,2006.485107421875],"size":[210,78.36762237548828],"flags":{},"order":7,"mode":0,"inputs":[{"name":"text","type":"STRING","link":6,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","300"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-607.1369018554688,1436.66015625],"size":[210,136.70285034179688],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[9,10],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,20\nGermany,3,30",0]},{"id":9,"type":"PandasCreate","pos":[-610.7672119140625,1838.9556884765625],"size":[210,113.97640228271484],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[11,12],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n10,100\n20,200\n30,300"]},{"id":8,"type":"PandasShowText","pos":[31.128482818603516,1601.9605712890625],"size":[210,78.36762237548828],"flags":{},"order":6,"mode":0,"inputs":[{"name":"text","type":"STRING","link":5,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","2"]},{"id":7,"type":"PandasLocCellStr","pos":[-294.200927734375,1601.82275390625],"size":[267.4131774902344,156.59359741210938],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":10}],"outputs":[{"name":"STRING","type":"STRING","links":[5],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocCellStr"},"widgets_values":["France","string","A","string"]},{"id":11,"type":"PandasLocCellStr","pos":[-291.8468933105469,2007.802734375],"size":[267.4131774902344,156.59359741210938],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":12}],"outputs":[{"name":"STRING","type":"STRING","links":[6],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocCellStr"},"widgets_values":["2","int","B","string"]}],"links":[[5,7,0,8,0,"STRING"],[6,11,0,12,0,"STRING"],[9,3,0,4,0,"DATAFRAME"],[10,3,0,7,0,"DATAFRAME"],[11,9,0,10,0,"DATAFRAME"],[12,9,0,11,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.7513148009015777,"offset":[1088.4491616447604,-1273.2553677671845]},"node_versions":{"data-analysis":"179365cb232c7f234cf9b9f0adcd7f63d2fd5f1d"},"ue_links":[]},"version":0.4}
|
||||
@@ -1 +1 @@
|
||||
{"last_node_id":18,"last_link_id":16,"nodes":[{"id":14,"type":"PandasSeriesToString","pos":[-75.9743423461914,1615.0836181640625],"size":[210,39.39631271362305],"flags":{},"order":6,"mode":0,"inputs":[{"name":"series_json","type":"STRING","link":12,"widget":{"name":"series_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[13],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasSeriesToString"},"widgets_values":[""]},{"id":10,"type":"PandasShowDataFrame","pos":[-332.0985412597656,1870.44482421875],"size":[210,116.62158966064453],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":7,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\n0 1 10\n1 2 2345678\n2 3 30"]},{"id":8,"type":"PandasShowText","pos":[175.51785278320312,1615.8155517578125],"size":[210,101.80709075927734],"flags":{},"order":8,"mode":0,"inputs":[{"name":"text","type":"STRING","link":13,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","A 2\nB 123456\nName: France, dtype: int64"]},{"id":16,"type":"PandasSeriesToString","pos":[-49.06276321411133,2046.5435791015625],"size":[210,39.39631271362305],"flags":{},"order":7,"mode":0,"inputs":[{"name":"series_json","type":"STRING","link":14,"widget":{"name":"series_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[16],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasSeriesToString"},"widgets_values":[""]},{"id":17,"type":"PandasShowText","pos":[201.8267822265625,2044.7362060546875],"size":[210,101.80709075927734],"flags":{},"order":9,"mode":0,"inputs":[{"name":"text","type":"STRING","link":16,"widget":{"name":"text"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasShowText"},"widgets_values":["","A 2\nB 2345678\nName: 1, dtype: int64"]},{"id":4,"type":"PandasShowDataFrame","pos":[-331.5325012207031,1436.6846923828125],"size":[210,116.62158966064453],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":2,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," A B\nUS 1 10\nFrance 2 123456\nGermany 3 30"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-594.9833374023438,1436.66015625],"size":[210,136.70285034179688],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[2,11],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,123456\nGermany,3,30",0]},{"id":9,"type":"PandasCreate","pos":[-609.8991088867188,1870.20849609375],"size":[210,113.97640228271484],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[7,15],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n1,10\n2,2345678\n3,30"]},{"id":13,"type":"PandasLocRowSeries","pos":[-337.280517578125,1615.083251953125],"size":[221.5128936767578,82.3223648071289],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":11,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[12],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasLocRowSeries"},"widgets_values":["","France","string"]},{"id":15,"type":"PandasLocRowSeries","pos":[-323.39080810546875,2047.4111328125],"size":[219.60301208496094,89.9618911743164],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":15,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[14],"slot_index":0,"localized_name":"STRING"}],"properties":{"Node name for S&R":"PandasLocRowSeries"},"widgets_values":["","1","int"]}],"links":[[2,3,0,4,0,"STRING"],[7,9,0,10,0,"STRING"],[11,3,0,13,0,"STRING"],[12,13,0,14,0,"STRING"],[13,14,0,8,0,"STRING"],[14,15,0,16,0,"STRING"],[15,9,0,15,0,"STRING"],[16,16,0,17,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.7853889628731393,"offset":[968.8282590918203,-1332.2955501507915]},"node_versions":{"data-analysis":"29af129ba3913df6cabbb3b7536c61317426759e"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":20,"last_link_id":22,"nodes":[{"id":4,"type":"PandasShowDataFrame","pos":[-331.5325012207031,1436.6846923828125],"size":[210,116.62158966064453],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":17}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\nindex \nUS 1 10\nFrance 2 123456\nGermany 3 30"]},{"id":3,"type":"PandasCreateWithIndex","pos":[-594.9833374023438,1436.66015625],"size":[210,136.70285034179688],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[17,18],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreateWithIndex"},"widgets_values":["index,A,B\nUS,1,10\nFrance,2,123456\nGermany,3,30",0]},{"id":9,"type":"PandasCreate","pos":[-609.8991088867188,1870.20849609375],"size":[210,113.97640228271484],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[21,22],"slot_index":0}],"properties":{"Node name for S&R":"PandasCreate"},"widgets_values":["A,B\n1,10\n2,2345678\n3,30"]},{"id":13,"type":"PandasLocRowSeries","pos":[-337.280517578125,1615.083251953125],"size":[221.5128936767578,82.3223648071289],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":18}],"outputs":[{"name":"PDSERIES","type":"PDSERIES","links":[19],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocRowSeries"},"widgets_values":["France","string"]},{"id":10,"type":"PandasShowDataFrame","pos":[-319.4935302734375,1858.7398681640625],"size":[210,116.62158966064453],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":21}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" A B\n0 1 10\n1 2 2345678\n2 3 30"]},{"id":15,"type":"PandasLocRowSeries","pos":[-323.39080810546875,2047.4111328125],"size":[219.60301208496094,89.9618911743164],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":22}],"outputs":[{"name":"PDSERIES","type":"PDSERIES","links":[20],"slot_index":0}],"properties":{"Node name for S&R":"PandasLocRowSeries"},"widgets_values":["2","int"]},{"id":20,"type":"PandasShowSeries","pos":[29.481536865234375,2052.40966796875],"size":[381.8376159667969,80.89225769042969],"flags":{},"order":7,"mode":0,"inputs":[{"name":"series_list","type":"PDSERIES","link":20}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowSeries"},"widgets_values":["{\"array\": [3, 30], \"index\": [\"A\", \"B\"], \"name\": 2}"]},{"id":19,"type":"PandasShowSeries","pos":[-17.823482513427734,1619.227294921875],"size":[432.7168884277344,80.89221954345703],"flags":{},"order":6,"mode":0,"inputs":[{"name":"series_list","type":"PDSERIES","link":19}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowSeries"},"widgets_values":["{\"array\": [2, 123456], \"index\": [\"A\", \"B\"], \"name\": \"France\"}"]}],"links":[[17,3,0,4,0,"DATAFRAME"],[18,3,0,13,0,"DATAFRAME"],[19,13,0,19,0,"PDSERIES"],[20,15,0,20,0,"PDSERIES"],[21,9,0,10,0,"DATAFRAME"],[22,9,0,15,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.8516904504832646,"offset":[1057.1888573958222,-1271.5413411458335]},"node_versions":{"data-analysis":"5a3046eb053b45f337768f0641e34bdb90450562"},"ue_links":[]},"version":0.4}
|
||||
@@ -1 +1 @@
|
||||
{"last_node_id":5,"last_link_id":5,"nodes":[{"id":1,"type":"PandasLoadCSV","pos":[353.8526611328125,2105.062255859375],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[2,4],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]},{"id":3,"type":"PandasSelectColumns","pos":[792.3731079101562,1956.5699462890625],"size":[349.8414306640625,115.1163558959961],"flags":{},"order":1,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":2,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[3],"slot_index":0}],"properties":{"Node name for S&R":"PandasSelectColumns"},"widgets_values":["","Name, Price"]},{"id":2,"type":"PandasShowDataFrame","pos":[1223.672119140625,1952.651123046875],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":3,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," Name Price\n0 fig 4.11\n1 safou 1.24\n2 papaya 5.11\n3 plum 2.53\n4 guava 0.66\n.. ... ...\n95 black currant 8.15\n96 red currant 7.71\n97 black currant 4.41\n98 red currant 2.18\n99 black currant 0.80\n\n[100 rows x 2 columns]"]},{"id":4,"type":"PandasSelectRows","pos":[780.7979125976562,2289.15966796875],"size":[390.7399597167969,111.2580337524414],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":4,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[5],"slot_index":0}],"properties":{"Node name for S&R":"PandasSelectRows"},"widgets_values":["","Price < 1"]},{"id":5,"type":"PandasShowDataFrame","pos":[1231.45263671875,2293.01708984375],"size":[301.1099548339844,161.65524291992188],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":5,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," Name Price InStock OnSale\n4 guava 0.66 1 1\n8 pawpaw 0.66 1 1\n17 orange 0.54 0 1\n78 santol 0.79 1 1\n91 black currant 0.51 1 0\n99 black currant 0.80 1 1"]}],"links":[[2,1,0,3,0,"STRING"],[3,3,0,2,0,"STRING"],[4,1,0,4,0,"STRING"],[5,4,0,5,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.8639278591604511,"offset":[-331.6863902845917,-1872.4571513539743]},"node_versions":{"ComfyUI-Data-Analysis":"235c84b7b8aafc3c4b904ba8f03c89aade96b640"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":9,"last_link_id":13,"nodes":[{"id":1,"type":"PandasLoadCSV","pos":[-86.53921508789062,1982.6943359375],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[6,7,12,13],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]},{"id":6,"type":"PandasColumns","pos":[109.43521118164062,1825.09326171875],"size":[216.59999084472656,26],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":12}],"outputs":[{"name":"PDINDEX","type":"PDINDEX","links":[10],"slot_index":0}],"properties":{"Node name for S&R":"PandasColumns"},"widgets_values":[]},{"id":3,"type":"PandasSelectColumns","pos":[792.3731079101562,1975.04443359375],"size":[349.8414306640625,115.1163558959961],"flags":{},"order":1,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":6}],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[8],"slot_index":0}],"properties":{"Node name for S&R":"PandasSelectColumns"},"widgets_values":["Name, Price"]},{"id":2,"type":"PandasShowDataFrame","pos":[1224.7589111328125,1972.2122802734375],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":8}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" Name Price\n0 fig 4.11\n1 safou 1.24\n2 papaya 5.11\n3 plum 2.53\n4 guava 0.66\n.. ... ...\n95 black currant 8.15\n96 red currant 7.71\n97 black currant 4.41\n98 red currant 2.18\n99 black currant 0.80\n\n[100 rows x 2 columns]"]},{"id":7,"type":"PandasIndex","pos":[99.6207275390625,2186.529541015625],"size":[216.59999084472656,26],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":13}],"outputs":[{"name":"PDINDEX","type":"PDINDEX","links":[11],"slot_index":0}],"properties":{"Node name for S&R":"PandasIndex"},"widgets_values":[]},{"id":9,"type":"PandasShowIndex","pos":[383.8125915527344,2184.78271484375],"size":[262.8389892578125,76],"flags":{},"order":8,"mode":0,"inputs":[{"name":"index_list","type":"PDINDEX","link":11}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowIndex"},"widgets_values":["RangeIndex(start=0, stop=100, step=1)"]},{"id":4,"type":"PandasSelectRows","pos":[780.7979125976562,2289.15966796875],"size":[390.7399597167969,111.2580337524414],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":7}],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[9],"slot_index":0}],"properties":{"Node name for S&R":"PandasSelectRows"},"widgets_values":["Price < 1"]},{"id":5,"type":"PandasShowDataFrame","pos":[1224.93212890625,2289.757080078125],"size":[311.3125305175781,171.71414184570312],"flags":{},"order":6,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":9}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" Name Price InStock OnSale\n4 guava 0.66 1 1\n8 pawpaw 0.66 1 1\n17 orange 0.54 0 1\n78 santol 0.79 1 1\n91 black currant 0.51 1 0\n99 black currant 0.80 1 1"]},{"id":8,"type":"PandasShowIndex","pos":[361.7475280761719,1823.6331787109375],"size":[404.7411804199219,76],"flags":{},"order":7,"mode":0,"inputs":[{"name":"index_list","type":"PDINDEX","link":10}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowIndex"},"widgets_values":["Index(['Name', 'Price', 'InStock', 'OnSale'], dtype='object')"]}],"links":[[6,1,0,3,0,"DATAFRAME"],[7,1,0,4,0,"DATAFRAME"],[8,3,0,2,0,"DATAFRAME"],[9,4,0,5,0,"DATAFRAME"],[10,6,0,8,0,"PDINDEX"],[11,7,0,9,0,"PDINDEX"],[12,1,0,6,0,"DATAFRAME"],[13,1,0,7,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.8435152048711749,"offset":[174.05797315870998,-1626.329224340914]},"node_versions":{"data-analysis":"1cefaf924bf9c92e0fbe79a9fd02aca04390ee57"},"ue_links":[]},"version":0.4}
|
||||
@@ -1 +1 @@
|
||||
{"last_node_id":8,"last_link_id":11,"nodes":[{"id":1,"type":"PandasLoadCSV","pos":[341.50604248046875,1996.256103515625],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"STRING","type":"STRING","links":[6],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]},{"id":6,"type":"PandasSort","pos":[797.7749633789062,1987.430908203125],"size":[210,132.86476135253906],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":6,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[8,10],"slot_index":0}],"properties":{"Node name for S&R":"PandasSort"},"widgets_values":["","Price",false]},{"id":7,"type":"PandasHead","pos":[794.6879272460938,2368.64111328125],"size":[210,91.96627807617188],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":10,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":[11],"slot_index":0}],"properties":{"Node name for S&R":"PandasHead"},"widgets_values":["",3]},{"id":8,"type":"MarkdownNote","pos":[786.199462890625,2250.57421875],"size":[227.97030639648438,68.48837280273438],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[],"properties":{},"widgets_values":["# Show top 3"],"color":"#432","bgcolor":"#653"},{"id":2,"type":"PandasShowDataFrame","pos":[1094.8031005859375,1988.14794921875],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":8,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," Name Price InStock OnSale\n34 mulberry 12.91 0 1\n77 apple 12.85 0 0\n49 grumichama 12.64 1 0\n47 rambutan 12.39 1 1\n15 kiwi 12.25 0 0\n.. ... ... ... ...\n78 santol 0.79 1 1\n8 pawpaw 0.66 1 1\n4 guava 0.66 1 1\n17 orange 0.54 0 1\n91 black currant 0.51 1 0\n\n[100 rows x 4 columns]"]},{"id":5,"type":"PandasShowDataFrame","pos":[1105.6707763671875,2374.0419921875],"size":[288.7632141113281,130.78851318359375],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe_json","type":"STRING","link":11,"widget":{"name":"dataframe_json"}}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[""," Name Price InStock OnSale\n34 mulberry 12.91 0 1\n77 apple 12.85 0 0\n49 grumichama 12.64 1 0"]}],"links":[[6,1,0,6,0,"STRING"],[8,6,0,2,0,"STRING"],[10,6,0,7,0,"STRING"],[11,7,0,5,0,"STRING"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.8639278591604511,"offset":[-331.6863902845917,-1872.4571513539743]},"node_versions":{"ComfyUI-Data-Analysis":"235c84b7b8aafc3c4b904ba8f03c89aade96b640"},"ue_links":[]},"version":0.4}
|
||||
{"last_node_id":8,"last_link_id":16,"nodes":[{"id":8,"type":"MarkdownNote","pos":[786.199462890625,2250.57421875],"size":[227.97030639648438,68.48837280273438],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[],"properties":{},"widgets_values":["# Show top 3"],"color":"#432","bgcolor":"#653"},{"id":2,"type":"PandasShowDataFrame","pos":[1094.8031005859375,1988.14794921875],"size":[323.9862976074219,238.33462524414062],"flags":{},"order":3,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":13}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" Name Price InStock OnSale\n34 mulberry 12.91 0 1\n77 apple 12.85 0 0\n49 grumichama 12.64 1 0\n47 rambutan 12.39 1 1\n15 kiwi 12.25 0 0\n.. ... ... ... ...\n78 santol 0.79 1 1\n8 pawpaw 0.66 1 1\n4 guava 0.66 1 1\n17 orange 0.54 0 1\n91 black currant 0.51 1 0\n\n[100 rows x 4 columns]"]},{"id":5,"type":"PandasShowDataFrame","pos":[1105.6707763671875,2374.0419921875],"size":[288.7632141113281,130.78851318359375],"flags":{},"order":5,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":15}],"outputs":[{"name":"STRING","type":"STRING","links":null,"shape":6}],"properties":{"Node name for S&R":"PandasShowDataFrame"},"widgets_values":[" Name Price InStock OnSale\n34 mulberry 12.91 0 1\n77 apple 12.85 0 0\n49 grumichama 12.64 1 0"]},{"id":1,"type":"PandasLoadCSV","pos":[341.50604248046875,1996.256103515625],"size":[410.5992736816406,95.68482208251953],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[12],"slot_index":0}],"properties":{"Node name for S&R":"PandasLoadCSV"},"widgets_values":["./custom_nodes/data-analysis/examples/datasets/fruit.csv"]},{"id":6,"type":"PandasSort","pos":[797.7749633789062,1987.430908203125],"size":[210,132.86476135253906],"flags":{},"order":2,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":12}],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[13,16],"slot_index":0}],"properties":{"Node name for S&R":"PandasSort"},"widgets_values":["Price",false]},{"id":7,"type":"PandasHead","pos":[794.6879272460938,2368.64111328125],"size":[210,91.96627807617188],"flags":{},"order":4,"mode":0,"inputs":[{"name":"dataframe","type":"DATAFRAME","link":16}],"outputs":[{"name":"DATAFRAME","type":"DATAFRAME","links":[15],"slot_index":0}],"properties":{"Node name for S&R":"PandasHead"},"widgets_values":[3]}],"links":[[12,1,0,6,0,"DATAFRAME"],[13,6,0,2,0,"DATAFRAME"],[15,7,0,5,0,"DATAFRAME"],[16,6,0,7,0,"DATAFRAME"]],"groups":[],"config":{},"extra":{"ds":{"scale":1,"offset":[-69.78740166232475,-1815.0490843278296]},"node_versions":{"data-analysis":"1cefaf924bf9c92e0fbe79a9fd02aca04390ee57"},"ue_links":[]},"version":0.4}
|
||||
File diff suppressed because one or more lines are too long
@@ -21,7 +21,7 @@ class CDAJSONCreate:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "create"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ def common_input_types():
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiscatter": True}),
|
||||
"dataframe": ("STRING", {"multiscatter": True}),
|
||||
"x_column_name": ("STRING", {"default": ""}),
|
||||
"y_column_name": ("STRING", {"default": ""}),
|
||||
"title": ("STRING", {"default": ""}),
|
||||
|
||||
@@ -26,7 +26,7 @@ class MPLBar:
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def bar_chart(self,
|
||||
dataframe_json: str,
|
||||
dataframe: pd.DataFrame,
|
||||
x_column_name: str,
|
||||
y_column_name: str,
|
||||
title: str,
|
||||
@@ -37,7 +37,7 @@ class MPLBar:
|
||||
Generates a bar chart from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
x_column_name (str): The column name for the x-axis.
|
||||
y_column_name (str): The column name for the y-axis.
|
||||
title (str): The title of the plot.
|
||||
@@ -49,8 +49,8 @@ class MPLBar:
|
||||
Returns:
|
||||
tuple: A tuple containing the image tensor representation of the plot.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
df = dataframe
|
||||
|
||||
# Create the plot
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
@@ -26,7 +26,7 @@ class MPLLine:
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def line_plot(self,
|
||||
dataframe_json: str,
|
||||
dataframe: pd.DataFrame,
|
||||
x_column_name: str,
|
||||
y_column_name: str,
|
||||
title: str,
|
||||
@@ -37,7 +37,7 @@ class MPLLine:
|
||||
Generates a line plot from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
x_column_name (str): The column name for the x-axis.
|
||||
y_column_name (str): The column name for the y-axis.
|
||||
title (str): The title of the plot.
|
||||
@@ -49,8 +49,8 @@ class MPLLine:
|
||||
Returns:
|
||||
tuple: A tuple containing the image tensor representation of the plot.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
df = dataframe
|
||||
|
||||
# Create the plot
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
@@ -26,7 +26,7 @@ class MPLScatter:
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def scatter_plot(self,
|
||||
dataframe_json: str,
|
||||
dataframe: pd.DataFrame,
|
||||
x_column_name: str,
|
||||
y_column_name: str,
|
||||
title: str,
|
||||
@@ -37,7 +37,7 @@ class MPLScatter:
|
||||
Generates a scatter plot from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
x_column_name (str): The column name for the x-axis.
|
||||
y_column_name (str): The column name for the y-axis.
|
||||
title (str): The title of the plot.
|
||||
@@ -49,8 +49,8 @@ class MPLScatter:
|
||||
Returns:
|
||||
tuple: A tuple containing the image tensor representation of the plot.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
df = dataframe
|
||||
|
||||
# Create the plot
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAdd:
|
||||
"""
|
||||
PandasAdd:
|
||||
A class for adding two pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Add two pandas DataFrames.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The left DataFrame.
|
||||
b_dataframe (DataFrame): The right DataFrame.
|
||||
on_column_name (str): The name of the column to join on.
|
||||
join_method (str): The type of join to perform ("inner", "left", "right", "outer").
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of addition.
|
||||
"""
|
||||
df_out = a_dataframe.add(b_dataframe)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasAddSeries:
|
||||
"""
|
||||
PandasAdd:
|
||||
A class for adding a Pandas Series to a pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Add two pandas DataFrames.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The left DataFrame.
|
||||
b_series (Series): The right Series.
|
||||
on_column_name (str): The name of the column to join on.
|
||||
join_method (str): The type of join to perform ("inner", "left", "right", "outer").
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of addition.
|
||||
"""
|
||||
df_out = a_dataframe.add(b_series)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,42 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAsFloat:
|
||||
"""
|
||||
PandasAsFloat:
|
||||
A class for converting all cells in a pandas DataFrame to float type.
|
||||
"""
|
||||
|
||||
@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:
|
||||
"""
|
||||
Converts all cells in the DataFrame to float type.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame with all values as floats.
|
||||
"""
|
||||
# Convert all values to float, non-numeric values become NaN
|
||||
df = dataframe.apply(pd.to_numeric, errors='coerce').astype(float)
|
||||
return (df,)
|
||||
@@ -0,0 +1,42 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAsInt:
|
||||
"""
|
||||
PandasAsInt:
|
||||
A class for converting all cells in a pandas DataFrame to integer type.
|
||||
"""
|
||||
|
||||
@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:
|
||||
"""
|
||||
Converts all cells in the DataFrame to integer type.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame with all values as integers.
|
||||
"""
|
||||
# Convert all values to integer, non-numeric values become NaN
|
||||
df = dataframe.apply(pd.to_numeric, errors='coerce').astype('Int64')
|
||||
return (df.to_json(),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAsString:
|
||||
"""
|
||||
PandasAsString:
|
||||
A class for converting all cells in a pandas DataFrame to string type.
|
||||
"""
|
||||
|
||||
@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 = "convert_to_string"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def convert_to_string(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Converts all cells in the DataFrame to string type.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame with all values as strings.
|
||||
"""
|
||||
# Convert all values to string
|
||||
df = dataframe.astype(str)
|
||||
return (df,)
|
||||
@@ -1,14 +1,13 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import index_to_jsons
|
||||
|
||||
|
||||
class PandasColumns:
|
||||
"""
|
||||
PandasColumns:
|
||||
A class for retrieving the column labels of a pandas DataFrame.
|
||||
"""
|
||||
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
@@ -19,25 +18,23 @@ class PandasColumns:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDINDEX",)
|
||||
FUNCTION: str = "columns"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def columns(self, dataframe_json: str) -> tuple:
|
||||
def columns(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns the column labels of a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the serialized pandas.Index containing columns.
|
||||
tuple: A tuple containing a pandas.Index for columns.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
columns = df.columns
|
||||
return (index_to_jsons(columns),)
|
||||
columns = dataframe.columns
|
||||
return (columns,)
|
||||
|
||||
@@ -19,24 +19,23 @@ class PandasCount:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with count for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.count()),)
|
||||
df = dataframe
|
||||
return (df.count(),)
|
||||
|
||||
@@ -23,7 +23,7 @@ class PandasCreate:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "create"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -39,8 +39,4 @@ class PandasCreate:
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(StringIO(data))
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -25,7 +25,7 @@ class PandasCreateWithIndex:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "create"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -43,8 +43,4 @@ class PandasCreateWithIndex:
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(StringIO(data), index_col=index_col)
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasDiv:
|
||||
"""
|
||||
PandasDiv:
|
||||
A class for dividing two pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Divide two pandas DataFrames.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The left DataFrame.
|
||||
b_dataframe (DataFrame): The right DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of division.
|
||||
"""
|
||||
df_out = a_dataframe.div(b_dataframe)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import jsons_to_series
|
||||
|
||||
class PandasDivSeries:
|
||||
"""
|
||||
PandasDivSeries:
|
||||
A class for dividing a Pandas DataFrame by a Pandas Series.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Divide a pandas DataFrame by a pandas Series.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The numerator DataFrame.
|
||||
b_series (Series): The denominator Series.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of division.
|
||||
"""
|
||||
df_out = a_dataframe.div(b_series)
|
||||
return (df_out,)
|
||||
@@ -1,7 +1,5 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import index_to_jsons
|
||||
|
||||
class PandasDropNA:
|
||||
"""
|
||||
@@ -19,24 +17,22 @@ class PandasDropNA:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "dropna"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def dropna(self, dataframe_json: str) -> tuple:
|
||||
def dropna(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a DataFrame with missing values removed.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (df.dropna().to_json(),)
|
||||
return (dataframe.dropna().to_json(),)
|
||||
|
||||
@@ -20,46 +20,43 @@ class PandasGroupBy:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"column_name": ("STRING", {"default": ""}),
|
||||
"aggragate_function":(("sum", "mean", "count", "std", "min", "max"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "groupby_dataframes"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def groupby_dataframes(self,
|
||||
dataframe_json: str,
|
||||
dataframe: pd.DataFrame,
|
||||
column_name: str,
|
||||
aggragate_function: str) -> tuple:
|
||||
"""
|
||||
Compute aggregate values for groups in a DataFrame
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
column_name (str): The name of the column for use as groups.
|
||||
aggregate_function (str): The type of aggregate function to perform.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the merged DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
if aggragate_function == "max":
|
||||
df_out = df.groupby(column_name).max()
|
||||
df_out = dataframe.groupby(column_name).max()
|
||||
elif aggragate_function == "min":
|
||||
df_out = df.groupby(column_name).min()
|
||||
df_out = dataframe.groupby(column_name).min()
|
||||
elif aggragate_function == "std":
|
||||
df_out = df.groupby(column_name).std()
|
||||
df_out = dataframe.groupby(column_name).std()
|
||||
elif aggragate_function == "count":
|
||||
df_out = df.groupby(column_name).count()
|
||||
df_out = dataframe.groupby(column_name).count()
|
||||
elif aggragate_function == "sum":
|
||||
df_out = df.groupby(column_name).sum()
|
||||
df_out = dataframe.groupby(column_name).sum()
|
||||
elif aggragate_function == "mean":
|
||||
df_out = df.groupby(column_name).mean()
|
||||
df_out = dataframe.groupby(column_name).mean()
|
||||
else:
|
||||
raise ValueError("Unsupported aggregate function.")
|
||||
return (df_out.to_json(),)
|
||||
return (df_out,)
|
||||
|
||||
@@ -19,27 +19,25 @@ class PandasHead:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"rows": ("INT", {"default": 10, "min": 0, "max": 50})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "head"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def head(self, dataframe_json: str, rows: int) -> tuple:
|
||||
def head(self, dataframe: pd.DataFrame, rows: int) -> tuple:
|
||||
"""
|
||||
Returns the first `rows` rows of a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
rows (int): The number of rows to retrieve.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the resulting DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
df2 = df.head(rows)
|
||||
return (df2.to_json(),)
|
||||
df2 = dataframe.head(rows)
|
||||
return (df2,)
|
||||
|
||||
@@ -21,30 +21,28 @@ class PandasIlocRowSeries:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "select_row"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def select_row(self, dataframe_json: str,
|
||||
def select_row(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int) -> tuple:
|
||||
"""
|
||||
Selects a specific row using a row label (row index) from a pandas DataFrame,
|
||||
and returns the JSON serialized Series object.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the row in string. The string is
|
||||
a JSON string containing the serialized Pandas Series object.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
value = df.iloc[row_integer_position]
|
||||
return (series_to_jsons(value),)
|
||||
value = dataframe.iloc[row_integer_position]
|
||||
return (value,)
|
||||
|
||||
@@ -21,16 +21,16 @@ class PandasIlocRowsDataFrame:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_int_pos_list_json": ("STRING", {"multiline": False})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "select_rows"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def select_rows(self, dataframe_json: str,
|
||||
def select_rows(self, dataframe: pd.DataFrame,
|
||||
row_int_pos_list_json: str) -> tuple:
|
||||
"""
|
||||
Select rows from a pandas DataFrame and returning it as a DataFrame.
|
||||
@@ -38,15 +38,13 @@ class PandasIlocRowsDataFrame:
|
||||
the JSON serialized DataFrame object.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_int_pos_list_json (str): A list containing row integer positions.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the row in string. The string is
|
||||
a JSON string containing the serialized Pandas Series object.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
row_int_pos_list = json.loads(row_int_pos_list_json)
|
||||
df2 = df.iloc[row_int_pos_list]
|
||||
return (df2.to_json(),)
|
||||
df2 = dataframe.iloc[row_int_pos_list]
|
||||
return (df2,)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import index_to_jsons
|
||||
|
||||
class PandasIndex:
|
||||
"""
|
||||
@@ -19,25 +17,23 @@ class PandasIndex:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDINDEX",)
|
||||
FUNCTION: str = "row_index"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def row_index(self, dataframe_json: str) -> tuple:
|
||||
def row_index(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns the row labels (index) of a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the serialized pandas.Index containing row labels.
|
||||
tuple: A tuple containing a pandas.Index for row labels.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
row_index = df.index
|
||||
return (index_to_jsons(row_index),)
|
||||
row_index = dataframe.index
|
||||
return (row_index,)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasIndexToString:
|
||||
"""
|
||||
PandasIndexToString:
|
||||
A class for converting a pandas Index to a string representation.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `to_string` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"index": ("PDINDEX", {}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, ind: pd.Index) -> tuple:
|
||||
"""
|
||||
Converts a Pandas Index to a string representation.
|
||||
|
||||
Args:
|
||||
ind (pd.Index): The index.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the string representation of the Index.
|
||||
"""
|
||||
return (str(ind),)
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import index_to_jsons
|
||||
|
||||
|
||||
class PandasIsNA:
|
||||
"""
|
||||
@@ -19,24 +18,22 @@ class PandasIsNA:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "isna"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def isna(self, dataframe_json: str) -> tuple:
|
||||
def isna(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a DataFrame with boolean values with True indicating a missing value.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (df.isna().to_json(),)
|
||||
return (dataframe.isna(),)
|
||||
|
||||
@@ -19,33 +19,29 @@ class PandasJoin:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"left_dataframe_json": ("STRING", {"multiline": True}),
|
||||
"right_dataframe_json": ("STRING", {"multiline": True}),
|
||||
"left_dataframe": ("DATAFRAME", {}),
|
||||
"right_dataframe": ("DATAFRAME", {}),
|
||||
"on_column_name": ("STRING", {"default": ""}),
|
||||
"join_method":(("inner", "left", "right", "outer"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "join_dataframes"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def join_dataframes(self, left_dataframe_json: str, right_dataframe_json: str, on_column_name: str, join_method: str) -> tuple:
|
||||
def join_dataframes(self, left_dataframe: pd.DataFrame, right_dataframe: pd.DataFrame, on_column_name: str, join_method: str) -> tuple:
|
||||
"""
|
||||
Merges two pandas DataFrames based on a common column using the specified join method.
|
||||
|
||||
Args:
|
||||
left_dataframe_json (str): A JSON string representation of the left DataFrame.
|
||||
right_dataframe_json (str): A JSON string representation of the right DataFrame.
|
||||
left_dataframe (DataFrame): The left DataFrame.
|
||||
right_dataframe (DataFrame): The right DataFrame.
|
||||
on_column_name (str): The name of the column to join on.
|
||||
join_method (str): The type of join to perform ("inner", "left", "right", "outer").
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the merged DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df_left = pd.read_json(StringIO(left_dataframe_json))
|
||||
df_right = pd.read_json(StringIO(right_dataframe_json))
|
||||
|
||||
df_out = pd.merge(df_left, df_right, on=on_column_name, how=join_method)
|
||||
return (df_out.to_json(),)
|
||||
df_out = pd.merge(left_dataframe, right_dataframe, on=on_column_name, how=join_method)
|
||||
return (df_out,)
|
||||
|
||||
@@ -23,7 +23,7 @@ class PandasLoadCSV:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "load_csv"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -39,8 +39,4 @@ class PandasLoadCSV:
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(file_path)
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -24,7 +24,7 @@ class PandasLoadCSVWithEncoding:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "load_csv"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -44,8 +44,4 @@ class PandasLoadCSVWithEncoding:
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(file_path, encoding=encoding)
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -25,7 +25,7 @@ class PandasLoadCSVWithIndex:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "load_csv"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -42,8 +42,4 @@ class PandasLoadCSVWithIndex:
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(file_path, index_col=index_col)
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -23,7 +23,7 @@ class PandasLoadJSON:
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "load_json"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@@ -39,8 +39,4 @@ class PandasLoadJSON:
|
||||
"""
|
||||
# Read JSON file into DataFrame
|
||||
df = pd.read_json(file_path)
|
||||
|
||||
# Convert DataFrame to JSON
|
||||
result_json = df.to_json()
|
||||
|
||||
return (result_json,)
|
||||
return (df,)
|
||||
|
||||
@@ -18,7 +18,7 @@ class PandasLocCellStr:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
@@ -30,7 +30,7 @@ class PandasLocCellStr:
|
||||
FUNCTION: str = "cell"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def cell(self, dataframe_json: str,
|
||||
def cell(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
@@ -39,7 +39,7 @@ class PandasLocCellStr:
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
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.
|
||||
@@ -48,10 +48,8 @@ class PandasLocCellStr:
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
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 = df.loc[row_index, column_label]
|
||||
value = dataframe.loc[row_index, column_label]
|
||||
return (str(value),)
|
||||
|
||||
@@ -19,35 +19,31 @@ class PandasLocRowSeries:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "select_row"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def select_row(self, dataframe_json: str,
|
||||
def select_row(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str) -> tuple:
|
||||
"""
|
||||
Selects a specific row using a row label (row index) from a pandas DataFrame,
|
||||
and returns the JSON serialized Series object.
|
||||
and returns the Series object.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_index (str): The row index (row label) for the row.
|
||||
row_index_type (str): The data type of the row index.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the row in string. The string is
|
||||
a JSON string containing the serialized Pandas Series object.
|
||||
tuple: A tuple containing the value of the row in the serialized Pandas Series object.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
row_index = int(row_index) if row_index_type == "int" else row_index
|
||||
|
||||
value = df.loc[row_index]
|
||||
return (series_to_jsons(value),)
|
||||
value = dataframe.loc[row_index]
|
||||
return (value,)
|
||||
|
||||
@@ -19,24 +19,22 @@ class PandasMax:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with max for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.max()),)
|
||||
return (dataframe.max(),)
|
||||
|
||||
@@ -19,24 +19,22 @@ class PandasMean:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with mean for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.mean()),)
|
||||
return (dataframe.mean(),)
|
||||
@@ -19,24 +19,22 @@ class PandasMedian:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with median for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.median()),)
|
||||
return (dataframe.median(),)
|
||||
|
||||
@@ -19,24 +19,22 @@ class PandasMin:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with min for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.min()),)
|
||||
return (dataframe.min(),)
|
||||
|
||||
@@ -18,24 +18,22 @@ class PandasMode:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a DataFrame with mode for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (df.mode().to_json(),)
|
||||
return (dataframe.mode(),)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasMul:
|
||||
"""
|
||||
PandasMul:
|
||||
A class for multiplying two pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Multiply two pandas DataFrames.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The left DataFrame.
|
||||
b_dataframe (DataFrame): The right DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of multiplication.
|
||||
"""
|
||||
df_out = a_dataframe.mul(b_dataframe)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import jsons_to_series
|
||||
|
||||
class PandasMulSeries:
|
||||
"""
|
||||
PandasMulSeries:
|
||||
A class for multiplying a Pandas DataFrame by a Pandas Series.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Multiply a pandas DataFrame by a pandas Series.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The DataFrame.
|
||||
b_series (Series): The Series.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of multiplication.
|
||||
"""
|
||||
df_out = a_dataframe.mul(b_series)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,46 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasPow:
|
||||
"""
|
||||
PandasPow:
|
||||
A class for exponentiating two pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
# "a_dataframe": ("DATAFRAME", {}),
|
||||
# "b_dataframe": ("DATAFRAME", {})
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
# def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Raise one pandas DataFrame to the power of another.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The base DataFrame.
|
||||
b_dataframe (DataFrame): The exponent DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of exponentiation.
|
||||
"""
|
||||
df_out = a_dataframe.pow(b_dataframe)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import jsons_to_series
|
||||
|
||||
class PandasPowSeries:
|
||||
"""
|
||||
PandasPowSeries:
|
||||
A class for raising a Pandas DataFrame to the power of a Pandas Series.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Raise a pandas DataFrame to the power of a pandas Series.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The base DataFrame.
|
||||
b_series (Series): The exponent Series.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of exponentiation.
|
||||
"""
|
||||
df_out = a_dataframe.pow(b_series)
|
||||
return (df_out,)
|
||||
@@ -17,7 +17,7 @@ class PandasSaveCSV:
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"forceInput": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"file_path": ("STRING", {"multiline": False})
|
||||
},
|
||||
"hidden": {
|
||||
@@ -34,7 +34,7 @@ class PandasSaveCSV:
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
def save_csv(self, dataframe_json,file_path=None, unique_id=None, extra_pnginfo=None):
|
||||
def save_csv(self, dataframe, file_path=None, unique_id=None, extra_pnginfo=None):
|
||||
text = None
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
@@ -47,8 +47,7 @@ class PandasSaveCSV:
|
||||
elif file_path is None or len(file_path) == 0:
|
||||
print("Error: file path is not specified")
|
||||
else:
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json[0]))
|
||||
df = dataframe[0]
|
||||
df.to_csv(path_or_buf=file_path[0]) # Save as CSV
|
||||
text = [str(df)] # wrap in list
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
|
||||
@@ -17,7 +17,7 @@ class PandasSaveJSON:
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"forceInput": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"file_path": ("STRING", {"multiline": False})
|
||||
},
|
||||
"hidden": {
|
||||
@@ -34,7 +34,7 @@ class PandasSaveJSON:
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
def save_json(self, dataframe_json,file_path=None, unique_id=None, extra_pnginfo=None):
|
||||
def save_json(self, dataframe, file_path=None, unique_id=None, extra_pnginfo=None):
|
||||
text = None
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
@@ -47,8 +47,7 @@ class PandasSaveJSON:
|
||||
elif file_path is None or len(file_path) == 0:
|
||||
print("Error: file path is not specified")
|
||||
else:
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json[0]))
|
||||
df = dataframe[0]
|
||||
df.to_json(path_or_buf=file_path[0]) # Save as JSON
|
||||
text = [str(df)] # wrap in list
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
|
||||
@@ -18,31 +18,26 @@ class PandasSelectColumns:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"column_names": ("STRING", {"default": ""})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "select_columns"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def select_columns(self, dataframe_json: str, column_names: str) -> tuple:
|
||||
def select_columns(self, dataframe: pd.DataFrame, column_names: str) -> tuple:
|
||||
"""
|
||||
Selects specific columns from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
column_names (str): A comma-separated string of column names to select.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the DataFrame with selected columns.
|
||||
tuple: A tuple containing the DataFrame with selected columns.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
# Process column names
|
||||
selected_columns = [col.strip() for col in column_names.split(",")]
|
||||
df2 = df[selected_columns]
|
||||
|
||||
return (df2.to_json(),)
|
||||
df2 = dataframe[selected_columns]
|
||||
return (df2,)
|
||||
|
||||
@@ -18,30 +18,26 @@ class PandasSelectRows:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"condition": ("STRING", {"default": ""})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "select_rows"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def select_rows(self, dataframe_json: str, condition: str) -> tuple:
|
||||
def select_rows(self, dataframe: pd.DataFrame, condition: str) -> tuple:
|
||||
"""
|
||||
Selects specific rows from a pandas DataFrame based on a given condition.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
condition (str): A string representing the condition to filter rows.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the filtered DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
# Apply condition
|
||||
df2 = df.query(condition)
|
||||
|
||||
return (df2.to_json(),)
|
||||
df2 = dataframe.query(condition)
|
||||
return (df2,)
|
||||
|
||||
@@ -19,7 +19,7 @@ class PandasSeriesToString:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"series_json": ("STRING", {"multiline": True}),
|
||||
"series": ("PDSERIES", {}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,16 +27,14 @@ class PandasSeriesToString:
|
||||
FUNCTION: str = "series_to_string"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def series_to_string(self, series_json: str) -> tuple:
|
||||
def series_to_string(self, series: pd.Series) -> tuple:
|
||||
"""
|
||||
Converts a Pandas Series to a string representation.
|
||||
|
||||
Args:
|
||||
series_json (str): A JSON string representation of the Series.
|
||||
series (Series): The Series.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the string representation of the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
series = jsons_to_series(series_json)
|
||||
return (str(series),)
|
||||
|
||||
@@ -12,7 +12,7 @@ class PandasShowDataFrame:
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"forceInput": True}),
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
},
|
||||
"hidden": {
|
||||
"unique_id": "UNIQUE_ID",
|
||||
@@ -28,7 +28,7 @@ class PandasShowDataFrame:
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
def notify(self, dataframe_json, unique_id=None, extra_pnginfo=None):
|
||||
def notify(self, dataframe, unique_id=None, extra_pnginfo=None):
|
||||
text = None
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
@@ -39,8 +39,7 @@ class PandasShowDataFrame:
|
||||
):
|
||||
print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
|
||||
else:
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json[0]))
|
||||
df = dataframe[0]
|
||||
text = [str(df)] # wrap in list
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
node = next(
|
||||
@@ -48,7 +47,11 @@ class PandasShowDataFrame:
|
||||
None,
|
||||
)
|
||||
if node:
|
||||
node["widgets_values"] = [text]
|
||||
node["widgets_values"] = text # [text]
|
||||
else:
|
||||
print("unique_id or extra_pnginfo is None.")
|
||||
return {"ui": {"text": text}, "result": (text,)}
|
||||
|
||||
# "ui" value is the one that is shown on the node UI.
|
||||
# Note that "ui" return value needs to a list of strings.
|
||||
return {"ui": {"text": text},
|
||||
"result": (text,)}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
This code is based on
|
||||
https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/main/py/show_text.py
|
||||
|
||||
See credit/credit.md for the full license.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
class PandasShowIndex:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"index_list": ("PDINDEX", {}),
|
||||
},
|
||||
"hidden": {
|
||||
"unique_id": "UNIQUE_ID",
|
||||
"extra_pnginfo": "EXTRA_PNGINFO",
|
||||
},
|
||||
}
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "notify"
|
||||
OUTPUT_NODE = True
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
def notify(self, index_list, unique_id=None, extra_pnginfo=None):
|
||||
text = None
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
print("Error: extra_pnginfo is not a list")
|
||||
elif (
|
||||
not isinstance(extra_pnginfo[0], dict)
|
||||
or "workflow" not in extra_pnginfo[0]
|
||||
):
|
||||
print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
|
||||
else:
|
||||
ind = index_list[0]
|
||||
text = [str(ind)] # wrap in list
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
node = next(
|
||||
(x for x in workflow["nodes"] if str(x["id"]) == str(unique_id[0])),
|
||||
None,
|
||||
)
|
||||
if node:
|
||||
node["widgets_values"] = [text]
|
||||
else:
|
||||
print("unique_id or extra_pnginfo is None.")
|
||||
return {"ui": {"text": text}, "result": (text,)}
|
||||
@@ -14,7 +14,7 @@ class PandasShowSeries:
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"series_json": ("STRING", {"forceInput": True}),
|
||||
"series_list": ("PDSERIES", {}),
|
||||
},
|
||||
"hidden": {
|
||||
"unique_id": "UNIQUE_ID",
|
||||
@@ -30,7 +30,7 @@ class PandasShowSeries:
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
def notify(self, series_json, unique_id=None, extra_pnginfo=None):
|
||||
def notify(self, series_list, unique_id=None, extra_pnginfo=None):
|
||||
text = None
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
@@ -41,8 +41,7 @@ class PandasShowSeries:
|
||||
):
|
||||
print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
|
||||
else:
|
||||
# Deserialize JSON string to DataFrame
|
||||
series = jsons_to_series(series_json[0])
|
||||
series = series_list[0]
|
||||
text = [series_to_jsons(series)] # wrap in list
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
node = next(
|
||||
|
||||
@@ -18,32 +18,27 @@ class PandasSort:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"column_name": ("STRING", {"default": ""}),
|
||||
"ascending": ("BOOLEAN", {"default": True})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "sort_rows"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def sort_rows(self, dataframe_json: str, column_name: str, ascending: bool) -> tuple:
|
||||
def sort_rows(self, dataframe: pd.DataFrame, column_name: str, ascending: bool) -> tuple:
|
||||
"""
|
||||
Sorts a pandas DataFrame by the specified column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
column_name (str): The name of the column to sort by.
|
||||
ascending (bool): Whether to sort in ascending order.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the sorted DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
# Sort DataFrame
|
||||
df2 = df.sort_values(by=column_name, ascending=ascending)
|
||||
|
||||
return (df2.to_json(),)
|
||||
df2 = dataframe.sort_values(by=column_name, ascending=ascending)
|
||||
return (df2,)
|
||||
|
||||
@@ -19,24 +19,22 @@ class PandasStd:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with standard deviation for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.std()),)
|
||||
return (dataframe.std(),)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasSub:
|
||||
"""
|
||||
PandasSub:
|
||||
A class for subtracting two pandas DataFrames.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Subtract two pandas DataFrames.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The left DataFrame.
|
||||
b_dataframe (DataFrame): The right DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of subtraction.
|
||||
"""
|
||||
df_out = a_dataframe.sub(b_dataframe)
|
||||
return (df_out,)
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
from .utils import jsons_to_series
|
||||
|
||||
class PandasSubSeries:
|
||||
"""
|
||||
PandasSubSeries:
|
||||
A class for subtracting a Pandas Series from a Pandas DataFrame.
|
||||
"""
|
||||
|
||||
@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": {
|
||||
"a_dataframe": ("DATAFRAME", {}),
|
||||
"b_series": ("PDSERIES", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, a_dataframe: pd.DataFrame, b_series: pd.Series) -> tuple:
|
||||
"""
|
||||
Subtract a pandas Series from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
a_dataframe (DataFrame): The DataFrame.
|
||||
b_series (Series): The Series.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame containing the result of subtraction.
|
||||
"""
|
||||
df_out = a_dataframe.sub(b_series)
|
||||
return (df_out,)
|
||||
@@ -19,24 +19,22 @@ class PandasSum:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with sum for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.sum()),)
|
||||
return (dataframe.sum(),)
|
||||
|
||||
@@ -18,28 +18,23 @@ class PandasSummary:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "analyze_dataframe"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def analyze_dataframe(self, dataframe_json: str) -> tuple:
|
||||
def analyze_dataframe(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Analyzes a pandas DataFrame and returns a summary.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a string representation of the DataFrame summary.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
|
||||
# Perform summary operation
|
||||
summary = df.describe()
|
||||
|
||||
summary = dataframe.describe()
|
||||
return (str(summary),)
|
||||
|
||||
@@ -18,7 +18,7 @@ class PandasToString:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True}),
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,14 @@ class PandasToString:
|
||||
FUNCTION: str = "to_string"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def to_string(self, dataframe_json: str) -> tuple:
|
||||
def to_string(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Converts a pandas DataFrame to a string representation.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the string representation of the DataFrame.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (str(df),)
|
||||
return (str(dataframe),)
|
||||
|
||||
@@ -19,24 +19,22 @@ class PandasVar:
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe_json": ("STRING", {"multiline": True})
|
||||
"dataframe": ("DATAFRAME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe_json: str) -> tuple:
|
||||
def f(self, dataframe: pd.DataFrame) -> tuple:
|
||||
"""
|
||||
Returns a Series with variance for each column.
|
||||
|
||||
Args:
|
||||
dataframe_json (str): A JSON string representation of the DataFrame.
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string for the Series.
|
||||
tuple: A tuple containing the Series.
|
||||
"""
|
||||
# Deserialize JSON string to DataFrame
|
||||
df = pd.read_json(StringIO(dataframe_json))
|
||||
return (series_to_jsons(df.var()),)
|
||||
return (dataframe.var(),)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "data-analysis"
|
||||
description = "Data analysis custom modules for ComfyUI - Use Pandas & Matplotlib within ComfyUI"
|
||||
version = "1.0.19"
|
||||
version = "1.1.0"
|
||||
license = {file = "LICENSE"}
|
||||
|
||||
[project.urls]
|
||||
|
||||
@@ -15,18 +15,20 @@ app.registerExtension({
|
||||
if (nodeData.name === "PandasShowDataFrame") { // This needs to match NODE_CLASS_MAPPINGS in Python
|
||||
function populate(text) {
|
||||
if (this.widgets) {
|
||||
for (let i = 1; i < this.widgets.length; i++) {
|
||||
// Clear all widgets on the node
|
||||
for (let i = 0; i < this.widgets.length; i++) {
|
||||
// if onRemove method exists, call it.
|
||||
this.widgets[i].onRemove?.();
|
||||
}
|
||||
this.widgets.length = 1;
|
||||
this.widgets.length = 0;
|
||||
}
|
||||
|
||||
const v = [...text];
|
||||
const v = [...text]; // Copy the text list (e.g. text.copy())
|
||||
if (!v[0]) {
|
||||
v.shift();
|
||||
}
|
||||
for (const list of v) {
|
||||
const w = ComfyWidgets["STRING"](this, "text2", ["STRING", { multiline: true }], app).widget;
|
||||
const w = ComfyWidgets["STRING"](this, "text0", ["STRING", { multiline: true }], app).widget;
|
||||
w.inputEl.readOnly = true;
|
||||
w.inputEl.style.opacity = 0.6;
|
||||
w.value = list;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
This code is based on
|
||||
https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/main/web/js/showText.js
|
||||
|
||||
See credit/credit.md for the full license.
|
||||
*/
|
||||
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { ComfyWidgets } from "../../../scripts/widgets.js";
|
||||
|
||||
// Displays input text on a node
|
||||
app.registerExtension({
|
||||
name: "HowToSD.ShowIndex",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === "PandasShowIndex") { // This needs to match NODE_CLASS_MAPPINGS in Python
|
||||
function populate(text) {
|
||||
if (this.widgets) {
|
||||
// Clear all widgets on the node
|
||||
for (let i = 0; i < this.widgets.length; i++) {
|
||||
// if onRemove method exists, call it.
|
||||
this.widgets[i].onRemove?.();
|
||||
}
|
||||
this.widgets.length = 0;
|
||||
}
|
||||
|
||||
const v = [...text]; // Copy the text list (e.g. text.copy())
|
||||
if (!v[0]) {
|
||||
v.shift();
|
||||
}
|
||||
for (const list of v) {
|
||||
const w = ComfyWidgets["STRING"](this, "text0", ["STRING", { multiline: true }], app).widget;
|
||||
w.inputEl.readOnly = true;
|
||||
w.inputEl.style.opacity = 0.6;
|
||||
w.value = list;
|
||||
}
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
const sz = this.computeSize();
|
||||
if (sz[0] < this.size[0]) {
|
||||
sz[0] = this.size[0];
|
||||
}
|
||||
if (sz[1] < this.size[1]) {
|
||||
sz[1] = this.size[1];
|
||||
}
|
||||
this.onResize?.(sz);
|
||||
app.graph.setDirtyCanvas(true, false);
|
||||
});
|
||||
}
|
||||
|
||||
// When the node is executed we will be sent the input text, display this in the widget
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted?.apply(this, arguments);
|
||||
populate.call(this, message.text);
|
||||
};
|
||||
|
||||
const onConfigure = nodeType.prototype.onConfigure;
|
||||
nodeType.prototype.onConfigure = function () {
|
||||
onConfigure?.apply(this, arguments);
|
||||
if (this.widgets_values?.length) {
|
||||
populate.call(this, this.widgets_values.slice(+this.widgets_values.length > 1));
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -15,18 +15,20 @@ app.registerExtension({
|
||||
if (nodeData.name === "PandasShowSeries") { // This needs to match NODE_CLASS_MAPPINGS in Python
|
||||
function populate(text) {
|
||||
if (this.widgets) {
|
||||
for (let i = 1; i < this.widgets.length; i++) {
|
||||
// Clear all widgets on the node
|
||||
for (let i = 0; i < this.widgets.length; i++) {
|
||||
// if onRemove method exists, call it.
|
||||
this.widgets[i].onRemove?.();
|
||||
}
|
||||
this.widgets.length = 1;
|
||||
this.widgets.length = 0;
|
||||
}
|
||||
|
||||
const v = [...text];
|
||||
const v = [...text]; // Copy the text list (e.g. text.copy())
|
||||
if (!v[0]) {
|
||||
v.shift();
|
||||
}
|
||||
for (const list of v) {
|
||||
const w = ComfyWidgets["STRING"](this, "text2", ["STRING", { multiline: true }], app).widget;
|
||||
const w = ComfyWidgets["STRING"](this, "text0", ["STRING", { multiline: true }], app).widget;
|
||||
w.inputEl.readOnly = true;
|
||||
w.inputEl.style.opacity = 0.6;
|
||||
w.value = list;
|
||||
|
||||
Reference in New Issue
Block a user