Added Pandas at, iat getter and setter nodes.
This commit is contained in:
+69
-3
@@ -7,9 +7,15 @@ from .modules.cda.cda_show_float import CDAShowFloat
|
||||
from .modules.cda.cda_show_int import CDAShowInt
|
||||
from .modules.cda.cda_string_create import CDAStringCreate
|
||||
from .modules.cda.cda_text_create import CDATextCreate
|
||||
from .modules.cda.py_datetime_to_string import PyDatetimeToString
|
||||
from .modules.cda.py_float_to_string import PyFloatToString
|
||||
from .modules.cda.py_int_to_string import PyIntToString
|
||||
from .modules.cda.py_kv_float_create import PyKvFloatCreate
|
||||
from .modules.cda.py_kv_int_create import PyKvIntCreate
|
||||
from .modules.cda.py_kv_string_create import PyKvStringCreate
|
||||
from .modules.cda.py_string_to_datetime import PyStringToDatetime
|
||||
from .modules.cda.py_string_to_float import PyStringToFloat
|
||||
from .modules.cda.py_string_to_int import PyStringToInt
|
||||
from .modules.matplotlib.mpl_bar import MPLBar
|
||||
from .modules.matplotlib.mpl_line import MPLLine
|
||||
from .modules.matplotlib.mpl_pie_chart import MPLPieChart
|
||||
@@ -25,6 +31,14 @@ 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_at_datetime import PandasAtDatetime
|
||||
from .modules.pandas_wrapper.pandas_at_float import PandasAtFloat
|
||||
from .modules.pandas_wrapper.pandas_at_int import PandasAtInt
|
||||
from .modules.pandas_wrapper.pandas_at_set_datetime import PandasAtSetDatetime
|
||||
from .modules.pandas_wrapper.pandas_at_set_float import PandasAtSetFloat
|
||||
from .modules.pandas_wrapper.pandas_at_set_int import PandasAtSetInt
|
||||
from .modules.pandas_wrapper.pandas_at_set_string import PandasAtSetString
|
||||
from .modules.pandas_wrapper.pandas_at_string import PandasAtString
|
||||
from .modules.pandas_wrapper.pandas_columns import PandasColumns
|
||||
from .modules.pandas_wrapper.pandas_corr import PandasCorr
|
||||
from .modules.pandas_wrapper.pandas_cos import PandasCos
|
||||
@@ -56,6 +70,14 @@ from .modules.pandas_wrapper.pandas_group_by import PandasGroupBy
|
||||
from .modules.pandas_wrapper.pandas_head import PandasHead
|
||||
from .modules.pandas_wrapper.pandas_horizontal_concat import PandasHorizontalConcat
|
||||
from .modules.pandas_wrapper.pandas_horizontal_split import PandasHorizontalSplit
|
||||
from .modules.pandas_wrapper.pandas_iat_datetime import PandasIatDatetime
|
||||
from .modules.pandas_wrapper.pandas_iat_float import PandasIatFloat
|
||||
from .modules.pandas_wrapper.pandas_iat_int import PandasIatInt
|
||||
from .modules.pandas_wrapper.pandas_iat_set_datetime import PandasIatSetDatetime
|
||||
from .modules.pandas_wrapper.pandas_iat_set_float import PandasIatSetFloat
|
||||
from .modules.pandas_wrapper.pandas_iat_set_int import PandasIatSetInt
|
||||
from .modules.pandas_wrapper.pandas_iat_set_string import PandasIatSetString
|
||||
from .modules.pandas_wrapper.pandas_iat_string import PandasIatString
|
||||
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_iloc_rows_slice_dataframe import PandasIlocRowsSliceDataFrame
|
||||
@@ -70,7 +92,7 @@ from .modules.pandas_wrapper.pandas_load_csv_with_index import PandasLoadCSVWith
|
||||
from .modules.pandas_wrapper.pandas_load_excel import PandasLoadExcel
|
||||
from .modules.pandas_wrapper.pandas_load_html import PandasLoadHTML
|
||||
from .modules.pandas_wrapper.pandas_load_json import PandasLoadJSON
|
||||
from .modules.pandas_wrapper.pandas_loc_cell_str import PandasLocCellStr
|
||||
from .modules.pandas_wrapper.pandas_loc_cell_string import PandasLocCellString
|
||||
from .modules.pandas_wrapper.pandas_loc_row_multiindex_dataframe import PandasLocRowMultiIndexDataFrame
|
||||
from .modules.pandas_wrapper.pandas_loc_row_series import PandasLocRowSeries
|
||||
from .modules.pandas_wrapper.pandas_log import PandasLog
|
||||
@@ -259,6 +281,14 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasAsFloat": PandasAsFloat,
|
||||
"PandasAsInt": PandasAsInt,
|
||||
"PandasAsString": PandasAsString,
|
||||
"PandasAtDatetime": PandasAtDatetime,
|
||||
"PandasAtFloat": PandasAtFloat,
|
||||
"PandasAtInt": PandasAtInt,
|
||||
"PandasAtSetDatetime": PandasAtSetDatetime,
|
||||
"PandasAtSetFloat": PandasAtSetFloat,
|
||||
"PandasAtSetInt": PandasAtSetInt,
|
||||
"PandasAtSetString": PandasAtSetString,
|
||||
"PandasAtString": PandasAtString,
|
||||
"PandasColumns": PandasColumns,
|
||||
"PandasCorr": PandasCorr,
|
||||
"PandasCos": PandasCos,
|
||||
@@ -290,6 +320,14 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasHead": PandasHead,
|
||||
"PandasHorizontalConcat": PandasHorizontalConcat,
|
||||
"PandasHorizontalSplit": PandasHorizontalSplit,
|
||||
"PandasIatDatetime": PandasIatDatetime,
|
||||
"PandasIatFloat": PandasIatFloat,
|
||||
"PandasIatInt": PandasIatInt,
|
||||
"PandasIatSetDatetime": PandasIatSetDatetime,
|
||||
"PandasIatSetFloat": PandasIatSetFloat,
|
||||
"PandasIatSetInt": PandasIatSetInt,
|
||||
"PandasIatSetString": PandasIatSetString,
|
||||
"PandasIatString": PandasIatString,
|
||||
"PandasIlocRowSeries": PandasIlocRowSeries,
|
||||
"PandasIlocRowsDataFrame": PandasIlocRowsDataFrame,
|
||||
"PandasIlocRowsSliceDataFrame": PandasIlocRowsSliceDataFrame,
|
||||
@@ -304,7 +342,7 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PandasLoadExcel": PandasLoadExcel,
|
||||
"PandasLoadHTML": PandasLoadHTML,
|
||||
"PandasLoadJSON": PandasLoadJSON,
|
||||
"PandasLocCellStr": PandasLocCellStr,
|
||||
"PandasLocCellString": PandasLocCellString,
|
||||
"PandasLocRowMultiIndexDataFrame": PandasLocRowMultiIndexDataFrame,
|
||||
"PandasLocRowSeries": PandasLocRowSeries,
|
||||
"PandasLog": PandasLog,
|
||||
@@ -455,9 +493,15 @@ NODE_CLASS_MAPPINGS: Dict[str, Type[T]] = {
|
||||
"PtvDataset": PtvDataset,
|
||||
"PtvDatasetLoader": PtvDatasetLoader,
|
||||
"PtvTransformsToTensor": PtvTransformsToTensor,
|
||||
"PyDatetimeToString": PyDatetimeToString,
|
||||
"PyFloatToString": PyFloatToString,
|
||||
"PyIntToString": PyIntToString,
|
||||
"PyKvFloatCreate": PyKvFloatCreate,
|
||||
"PyKvIntCreate": PyKvIntCreate,
|
||||
"PyKvStringCreate": PyKvStringCreate,
|
||||
"PyStringToDatetime": PyStringToDatetime,
|
||||
"PyStringToFloat": PyStringToFloat,
|
||||
"PyStringToInt": PyStringToInt,
|
||||
"SNSBar": SNSBar,
|
||||
"SNSBoxplot": SNSBoxplot,
|
||||
"SNSHeatmap": SNSHeatmap,
|
||||
@@ -496,6 +540,14 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasAsFloat": "Pandas As Float",
|
||||
"PandasAsInt": "Pandas As Int",
|
||||
"PandasAsString": "Pandas As String",
|
||||
"PandasAtDatetime": "Pandas At Datetime",
|
||||
"PandasAtFloat": "Pandas At Float",
|
||||
"PandasAtInt": "Pandas At Int",
|
||||
"PandasAtSetDatetime": "Pandas At Set Datetime",
|
||||
"PandasAtSetFloat": "Pandas At Set Float",
|
||||
"PandasAtSetInt": "Pandas At Set Int",
|
||||
"PandasAtSetString": "Pandas At Set String",
|
||||
"PandasAtString": "Pandas At String",
|
||||
"PandasColumns": "Pandas Columns",
|
||||
"PandasCorr": "Pandas Corr",
|
||||
"PandasCos": "Pandas Cos",
|
||||
@@ -527,6 +579,14 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasHead": "Pandas Head",
|
||||
"PandasHorizontalConcat": "Pandas Horizontal Concat",
|
||||
"PandasHorizontalSplit": "Pandas Horizontal Split",
|
||||
"PandasIatDatetime": "Pandas Iat Datetime",
|
||||
"PandasIatFloat": "Pandas Iat Float",
|
||||
"PandasIatInt": "Pandas Iat Int",
|
||||
"PandasIatSetDatetime": "Pandas Iat Set Datetime",
|
||||
"PandasIatSetFloat": "Pandas Iat Set Float",
|
||||
"PandasIatSetInt": "Pandas Iat Set Int",
|
||||
"PandasIatSetString": "Pandas Iat Set String",
|
||||
"PandasIatString": "Pandas Iat String",
|
||||
"PandasIlocRowSeries": "Pandas Iloc Row Series",
|
||||
"PandasIlocRowsDataFrame": "Pandas Iloc Rows DataFrame",
|
||||
"PandasIlocRowsSliceDataFrame": "Pandas Iloc Rows Slice DataFrame",
|
||||
@@ -541,7 +601,7 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PandasLoadExcel": "Pandas Load Excel",
|
||||
"PandasLoadHTML": "Pandas Load HTML",
|
||||
"PandasLoadJSON": "Pandas Load JSON",
|
||||
"PandasLocCellStr": "Pandas Loc Cell Str",
|
||||
"PandasLocCellString": "Pandas Loc Cell String",
|
||||
"PandasLocRowMultiIndexDataFrame": "Pandas Loc Row MultiIndex DataFrame",
|
||||
"PandasLocRowSeries": "Pandas Loc Row Series",
|
||||
"PandasLog": "Pandas Log",
|
||||
@@ -692,9 +752,15 @@ NODE_DISPLAY_NAME_MAPPINGS: Dict[str, str] = {
|
||||
"PtvDataset": "Ptv Dataset",
|
||||
"PtvDatasetLoader": "Ptv Dataset Loader",
|
||||
"PtvTransformsToTensor": "Ptv Transforms To Tensor",
|
||||
"PyDatetimeToString": "Py Datetime To String",
|
||||
"PyFloatToString": "Py Float To String",
|
||||
"PyIntToString": "Py Int To String",
|
||||
"PyKvFloatCreate": "Py Kv Float Create",
|
||||
"PyKvIntCreate": "Py Kv Int Create",
|
||||
"PyKvStringCreate": "Py Kv String Create",
|
||||
"PyStringToDatetime": "Py String To Datetime",
|
||||
"PyStringToFloat": "Py String To Float",
|
||||
"PyStringToInt": "Py String To Int",
|
||||
"SNSBar": "SNS Bar Chart",
|
||||
"SNSBoxplot": "SNS Boxplot",
|
||||
"SNSHeatmap": "SNS Heatmap",
|
||||
|
||||
@@ -50,11 +50,19 @@
|
||||
## Data subset selection
|
||||
| Node | Description |
|
||||
| --- | --- |
|
||||
| [Pandas At Datetime](pandas_at_datetime.md) | Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data. |
|
||||
| [Pandas At Float](pandas_at_float.md) | Selects a cell from a pandas DataFrame and output as a Python float. |
|
||||
| [Pandas At Int](pandas_at_int.md) | Selects a cell from a pandas DataFrame and output as a Python int. |
|
||||
| [Pandas At String](pandas_at_string.md) | Selects a cell from a pandas DataFrame and output as a string. |
|
||||
| [Pandas Head](pandas_head.md) | Retrieves the first few rows of a pandas DataFrame. |
|
||||
| [Pandas Iat Datetime](pandas_iat_datetime.md) | Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data. |
|
||||
| [Pandas Iat Float](pandas_iat_float.md) | Selects a cell from a pandas DataFrame and output as a Python float. |
|
||||
| [Pandas Iat Int](pandas_iat_int.md) | Selects a cell from a pandas DataFrame and output as a Python int. |
|
||||
| [Pandas Iat String](pandas_iat_string.md) | Selects a cell from a pandas DataFrame and output as a string. |
|
||||
| [Pandas Iloc Row Series](pandas_iloc_row_series.md) | Selects a row from a pandas DataFrame and returning it as a Series. |
|
||||
| [Pandas Iloc Rows Data Frame](pandas_iloc_rows_dataframe.md) | Selects rows from a pandas DataFrame and returning it as a DataFrame. |
|
||||
| [Pandas Iloc Rows Slice Data Frame](pandas_iloc_rows_slice_dataframe.md) | Selects rows from a pandas DataFrame using a slice defined by a start and end integer position. The start position is inclusive, while the end position is exclusive. Returns the selected rows as a DataFrame. |
|
||||
| [Pandas Loc Cell Str](pandas_loc_cell_str.md) | Selects a cell from a pandas DataFrame and output as a string. |
|
||||
| [Pandas Loc Cell String](pandas_loc_cell_string.md) | Selects a cell from a pandas DataFrame and output as a string. |
|
||||
| [Pandas Loc Row MultiIndex DataFrame](pandas_loc_row_multiindex_dataframe.md) | Selects a row or rows from a pandas DataFrame with MultiIndex and output as a DataFrame. |
|
||||
| [Pandas Loc Row Series](pandas_loc_row_series.md) | Selects a row from a pandas DataFrame and output as a Series. |
|
||||
| [Pandas Select Columns](pandas_select_columns.md) | Selects specific columns from a pandas DataFrame. |
|
||||
@@ -280,9 +288,15 @@
|
||||
## Python wrapper
|
||||
| Node | Description |
|
||||
| --- | --- |
|
||||
| [Py Datetime To String](py_datetime_to_string.md) | Converts a Python datetime.datetime value to a Python string |
|
||||
| [Py Float To String](py_float_to_string.md) | Converts a Python float value to a Python string |
|
||||
| [Py Int To String](py_int_to_string.md) | Converts a Python int value to a Python string |
|
||||
| [Py Kv Float Create](py_kv_float_create.md) | Creates a Python dictionary with a string key and a float value. |
|
||||
| [Py Kv Int Create](py_kv_int_create.md) | Creates a Python dictionary with an string key and an integer value. |
|
||||
| [Py Kv String Create](py_kv_string_create.md) | Creates a Python dictionary with a string key and a string value. |
|
||||
| [Py String To Datetime](py_string_to_datetime.md) | Converts a Python string to a Python datetime.datetime. |
|
||||
| [Py String To Float](py_string_to_float.md) | Converts a Python string to a float. |
|
||||
| [Py String To Int](py_string_to_int.md) | Converts a Python string to an int. |
|
||||
## Summary statistics
|
||||
| Node | Description |
|
||||
| --- | --- |
|
||||
@@ -303,9 +317,17 @@
|
||||
## Transformation
|
||||
| Node | Description |
|
||||
| --- | --- |
|
||||
| [Pandas At Set Datetime](pandas_at_set_datetime.md) | Sets a Python datetime.datetime data in a cell in a pandas DataFrame. |
|
||||
| [Pandas At Set Float](pandas_at_set_float.md) | Sets a Python float data in a cell in a pandas DataFrame. |
|
||||
| [Pandas At Set Int](pandas_at_set_int.md) | Sets a Python int data in a cell in a pandas DataFrame. |
|
||||
| [Pandas At Set String](pandas_at_set_string.md) | Sets a Python string data in a cell in a pandas DataFrame. |
|
||||
| [Pandas Feature Split To Numpy](pandas_feature_split_to_numpy.md) | Splits a Pandas DataFrame into feature Numpy ndarray and label Numpy ndarray. |
|
||||
| [Pandas Horizontal Concat](pandas_horizontal_concat.md) | Horizontally concatenates two pandas DataFrames. |
|
||||
| [Pandas Horizontal Split](pandas_horizontal_split.md) | Horizontally splits a Pandas DataFrame into two pandas DataFrames. |
|
||||
| [Pandas Iat Set Datetime](pandas_iat_set_datetime.md) | Sets a Python datetime.datetime data in a cell in a pandas DataFrame. |
|
||||
| [Pandas Iat Set Float](pandas_iat_set_float.md) | Sets a Python float data in a cell from a pandas DataFrame. |
|
||||
| [Pandas Iat Set Int](pandas_iat_set_int.md) | Sets a Python int data in a cell from a pandas DataFrame. |
|
||||
| [Pandas Iat Set String](pandas_iat_set_string.md) | Sets a Python string in a cell in a pandas DataFrame. |
|
||||
| [Pandas Join](pandas_join.md) | Merges two pandas DataFrames based on a common column. |
|
||||
| [Pandas Melt](pandas_melt.md) | Performs an unpivot operation (melt) on a pandas DataFrame. |
|
||||
| [Pandas Pivot](pandas_pivot.md) | Computes a pivot table from a pandas DataFrame. |
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Pandas At Datetime
|
||||
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Pydatetime |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Pandas At Float
|
||||
Selects a cell from a pandas DataFrame and output as a Python float.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Float |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Pandas At Int
|
||||
Selects a cell from a pandas DataFrame and output as a Python int.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Int |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Pandas At Set Datetime
|
||||
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
| data | Pydatetime |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Pandas At Set Float
|
||||
Sets a Python float data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
| data | Float |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Pandas At Set Int
|
||||
Sets a Python int data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
| data | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Pandas At Set String
|
||||
Sets a Python string data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
| data | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -1,4 +1,4 @@
|
||||
# Pandas Loc Cell Str
|
||||
# Pandas At String
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
## Input
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pandas Iat Datetime
|
||||
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Pydatetime |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pandas Iat Float
|
||||
Selects a cell from a pandas DataFrame and output as a Python float.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Float |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pandas Iat Int
|
||||
Selects a cell from a pandas DataFrame and output as a Python int.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Int |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Pandas Iat Set Datetime
|
||||
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
| data | Pydatetime |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Pandas Iat Set Float
|
||||
Sets a Python float data in a cell from a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
| data | Float |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Pandas Iat Set Int
|
||||
Sets a Python int data in a cell from a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
| data | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,22 @@
|
||||
# Pandas Iat Set String
|
||||
Sets a Python string in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
| data | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| DataFrame |
|
||||
|
||||
<HR>
|
||||
Category: Transformation
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Pandas Iat String
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_integer_position | Int |
|
||||
| column_integer_position | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| String |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Pandas Loc Cell String
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| dataframe | DataFrame |
|
||||
| row_index | String |
|
||||
| row_index_type | |
|
||||
| column_label | String |
|
||||
| column_label_type | |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| String |
|
||||
|
||||
<HR>
|
||||
Category: Data subset selection
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -1,17 +0,0 @@
|
||||
# Conv Single Layer
|
||||
A single convolutional layer followed by an optional ReLU activation and optional downsampling.
|
||||
|
||||
Shape is tensor of shape `(batch_size, in_channels, height, width)`.
|
||||
|
||||
Args:
|
||||
in_channels (int): Number of input channels.
|
||||
out_channels (int): Number of output channels.
|
||||
kernel_size (int): Size of the convolutional kernel.
|
||||
padding (int): Padding size for convolution.
|
||||
downsample (bool): If True, applies a 2x2 MaxPooling layer.
|
||||
apply_activation (bool, optional): If True, applies ReLU activation. Defaults to True.
|
||||
|
||||
<HR>
|
||||
Category: Miscellaneous
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -1,20 +0,0 @@
|
||||
# Dense Model
|
||||
A multi-layer dense neural network with ReLU activation after each dense layer, except for the final layer.
|
||||
|
||||
Args:
|
||||
dim_list (List[int]): List of feature dimensions. Should be of length `num_layers + 1`.
|
||||
bias_list (List[bool]): List indicating whether each layer should have a bias.
|
||||
num_layers (int): Number of layers in the model.
|
||||
|
||||
Example:
|
||||
For a three-layer network:
|
||||
- Layer 1: input -> output1
|
||||
- Layer 2: output1 -> output2
|
||||
- Layer 3: output2 -> output3
|
||||
|
||||
`dim_list = [input_dim, output1_dim, output2_dim, output3_dim]`
|
||||
|
||||
<HR>
|
||||
Category: Miscellaneous
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Py Datetime To String
|
||||
Converts a Python datetime.datetime value to a Python string
|
||||
|
||||
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | Pydatetime |
|
||||
| date_format | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| String |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Py Float To String
|
||||
Converts a Python float value to a Python string
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | Float |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| String |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Py Int To String
|
||||
Converts a Python int value to a Python string
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | Int |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| String |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Py String To Datetime
|
||||
Converts a Python string to a Python datetime.datetime.
|
||||
|
||||
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | String |
|
||||
| date_format | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Pydatetime |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Py String To Float
|
||||
Converts a Python string to a float.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Float |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Py String To Int
|
||||
Converts a Python string to an int.
|
||||
|
||||
## Input
|
||||
| Name | Data type |
|
||||
|---|---|
|
||||
| value | String |
|
||||
|
||||
## Output
|
||||
| Data type |
|
||||
|---|
|
||||
| Int |
|
||||
|
||||
<HR>
|
||||
Category: Python wrapper
|
||||
|
||||
ComfyUI Data Analysis Node Reference. © 2025 Hide Inada (HowToSD.com). All rights reserved.
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from datetime import datetime
|
||||
|
||||
class PyDatetimeToString:
|
||||
"""
|
||||
Converts a Python datetime.datetime value to a Python string
|
||||
|
||||
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("PYDATETIME", {}),
|
||||
"date_format": ("STRING", {"default":"%Y-%m-%d %H:%M:%S", "multiline": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: datetime, date_format: str) -> tuple:
|
||||
"""
|
||||
Converts a Python datetime.datetime value to a Python string
|
||||
|
||||
Args:
|
||||
value (str): String value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the converted value.
|
||||
"""
|
||||
return (datetime.strftime(value, date_format),)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Dict
|
||||
import datetime
|
||||
|
||||
class PyFloatToString:
|
||||
"""
|
||||
Converts a Python float value to a Python string
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: float) -> tuple:
|
||||
"""
|
||||
Converts a Python float value to a Python string
|
||||
|
||||
Args:
|
||||
value (float): Float value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the converted value.
|
||||
"""
|
||||
return (str(value),)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
class PyIntToString:
|
||||
"""
|
||||
Converts a Python int value to a Python string
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: int) -> tuple:
|
||||
"""
|
||||
Converts a Python int value to a Python string
|
||||
|
||||
Args:
|
||||
value (int): Int value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the converted value.
|
||||
"""
|
||||
return (str(value),)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict
|
||||
from datetime import datetime
|
||||
|
||||
class PyStringToDatetime:
|
||||
"""
|
||||
Converts a Python string to a Python datetime.datetime.
|
||||
|
||||
Refer to [the Python documentation](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for date/time format strings.
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("STRING", {"default":"", "multiline": False}),
|
||||
"date_format": ("STRING", {"default":"%Y-%m-%d %H:%M:%S", "multiline": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PYDATETIME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: str, date_format: str) -> tuple:
|
||||
"""
|
||||
Converts a Python string to Python datetime.datetime.
|
||||
|
||||
Args:
|
||||
value (str): String value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the dictionary.
|
||||
"""
|
||||
return (datetime.strptime(value, date_format),)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
class PyStringToFloat:
|
||||
"""
|
||||
Converts a Python string to a float.
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("STRING", {"default":"", "multiline": False})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("FLOAT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: str) -> tuple:
|
||||
"""
|
||||
Converts a Python string to a float.
|
||||
|
||||
Args:
|
||||
value (str): String value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the dictionary.
|
||||
"""
|
||||
return (float(value),)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
class PyStringToInt:
|
||||
"""
|
||||
Converts a Python string to an int.
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `create` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("STRING", {"default":"", "multiline": False})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("INT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: str) -> tuple:
|
||||
"""
|
||||
Converts a Python string to an int.
|
||||
|
||||
Args:
|
||||
value (str): String value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the dictionary.
|
||||
"""
|
||||
return (int(value),)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
import datetime
|
||||
|
||||
|
||||
class PandasAtDatetime:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PYDATETIME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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 = dataframe.at[row_index, column_label]
|
||||
return (value.to_pydatetime(),)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasAtFloat:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python float.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("FLOAT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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 = dataframe.at[row_index, column_label]
|
||||
return (float(value),)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasAtInt:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python int.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("INT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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 = dataframe.at[row_index, column_label]
|
||||
return (int(value),)
|
||||
@@ -0,0 +1,62 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
import datetime
|
||||
|
||||
|
||||
class PandasAtSetDatetime:
|
||||
"""
|
||||
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),),
|
||||
"data": ("PYDATETIME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str,
|
||||
data: datetime.datetime) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
data: datetime.datetime (datetime.datetime): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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
|
||||
|
||||
dataframe.at[row_index, column_label] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,61 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAtSetFloat:
|
||||
"""
|
||||
Sets a Python float data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),),
|
||||
"data": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str,
|
||||
data: float) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
data: float (float): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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
|
||||
|
||||
dataframe.at[row_index, column_label] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,61 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAtSetInt:
|
||||
"""
|
||||
Sets a Python int data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),),
|
||||
"data": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str,
|
||||
data: int) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
data: int (int): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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
|
||||
|
||||
dataframe.at[row_index, column_label] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,61 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasAtSetString:
|
||||
"""
|
||||
Sets a Python string data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),),
|
||||
"data": ("STRING", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str,
|
||||
data: str) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
data: string (str): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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
|
||||
|
||||
dataframe.at[row_index, column_label] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,56 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasAtString:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_index": ("STRING", {"default": ""}),
|
||||
"row_index_type":(("string", "int"),),
|
||||
"column_label": ("STRING", {"default": ""}),
|
||||
"column_label_type":(("string", "int"),)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
column_label_type: str) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
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.
|
||||
column_label_type (str): The data type of the column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell in string.
|
||||
"""
|
||||
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 = dataframe.at[row_index, column_label]
|
||||
return (value,)
|
||||
@@ -0,0 +1,48 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
import datetime
|
||||
|
||||
|
||||
class PandasIatDatetime:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python datetime.datetime data.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PYDATETIME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell.
|
||||
"""
|
||||
value = dataframe.iat[row_integer_position, column_integer_position]
|
||||
return (value.to_pydatetime(),)
|
||||
@@ -0,0 +1,46 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasIatFloat:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python float.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("FLOAT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell.
|
||||
"""
|
||||
value = dataframe.iat[row_integer_position, column_integer_position]
|
||||
return (float(value),)
|
||||
@@ -0,0 +1,47 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasIatInt:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a Python int.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("INT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell.
|
||||
"""
|
||||
value = dataframe.iat[row_integer_position, column_integer_position]
|
||||
return (int(value),)
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
import datetime
|
||||
|
||||
class PandasIatSetDatetime:
|
||||
"""
|
||||
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"data": ("PYDATETIME", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int,
|
||||
data: datetime.datetime) -> tuple:
|
||||
"""
|
||||
Sets a Python datetime.datetime data in a cell in a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
data: datetime.datetime (datetime.datetime): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the updated DataFrame.
|
||||
"""
|
||||
dataframe.iat[row_integer_position, column_integer_position] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasIatSetFloat:
|
||||
"""
|
||||
Sets a Python float data in a cell from a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"data": ("FLOAT", {"default": 0, "min": -2**63, "max": 2**63, "step": 0.00000001})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int,
|
||||
data: float) -> tuple:
|
||||
"""
|
||||
Sets a Python float data in a cell in a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
data (float): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the updated DataFrame.
|
||||
"""
|
||||
dataframe.iat[row_integer_position, column_integer_position] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasIatSetInt:
|
||||
"""
|
||||
Sets a Python int data in a cell from a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"data": ("INT", {"default": 0, "min": -2**31, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int,
|
||||
data: int) -> tuple:
|
||||
"""
|
||||
Sets a Python int data in a cell in a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
data (int): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the updated DataFrame.
|
||||
"""
|
||||
dataframe.iat[row_integer_position, column_integer_position] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
import datetime
|
||||
|
||||
class PandasIatSetString:
|
||||
"""
|
||||
Sets a Python string in a cell in a pandas DataFrame.
|
||||
|
||||
This modifies the input DataFrame in place.
|
||||
|
||||
category: Transformation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"data": ("STRING", {"default": ""})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("DATAFRAME",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int,
|
||||
data: str) -> tuple:
|
||||
"""
|
||||
Sets a Python string data in a cell in a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
data: string (str): The value to set in the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the updated DataFrame.
|
||||
"""
|
||||
dataframe.iat[row_integer_position, column_integer_position] = data
|
||||
return (dataframe,)
|
||||
@@ -0,0 +1,47 @@
|
||||
from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasIatString:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
category: Data subset selection
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the `cell` function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"row_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31}),
|
||||
"column_integer_position": ("INT", {"default": 0, "min": 0, "max": 2**31})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_integer_position: int,
|
||||
column_integer_position: int) -> tuple:
|
||||
"""
|
||||
Selects specific cell from a pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
row_integer_position (int): The row integer position for the cell.
|
||||
column_integer_position (int): The row integer position for the cell.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the cell.
|
||||
"""
|
||||
value = dataframe.iat[row_integer_position, column_integer_position]
|
||||
return (value,)
|
||||
+3
-3
@@ -2,7 +2,7 @@ from typing import Any, Dict
|
||||
from io import StringIO
|
||||
import pandas as pd
|
||||
|
||||
class PandasLocCellStr:
|
||||
class PandasLocCellString:
|
||||
"""
|
||||
Selects a cell from a pandas DataFrame and output as a string.
|
||||
|
||||
@@ -28,10 +28,10 @@ class PandasLocCellStr:
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "cell"
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def cell(self, dataframe: pd.DataFrame,
|
||||
def f(self, dataframe: pd.DataFrame,
|
||||
row_index: str,
|
||||
row_index_type: str,
|
||||
column_label: str,
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "data-analysis"
|
||||
description = "Data analysis custom modules for ComfyUI – Integrates Pandas, Seaborn and Matplotlib into ComfyUI, featuring extensive PyTorch wrapper nodes for seamless tensor operations. Experimental PyTorch model training was added in v2.0."
|
||||
version = "2.0.5"
|
||||
version = "2.0.6"
|
||||
license = {file = "LICENSE"}
|
||||
|
||||
[project.urls]
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_datetime_to_string import PyDatetimeToString
|
||||
|
||||
class TestPyDatetimeToString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyDatetimeToString()
|
||||
self.test_cases = [
|
||||
(datetime(2023, 3, 15, 12, 0, 0), "%Y-%m-%d %H:%M:%S", "2023-03-15 12:00:00"),
|
||||
(datetime(2024, 6, 1, 9, 30, 0), "%Y-%m-%d %H:%M:%S", "2024-06-01 09:30:00"),
|
||||
(datetime(2023, 3, 15, 12, 0), "%d/%m/%Y %H:%M", "15/03/2023 12:00"),
|
||||
(datetime(2024, 6, 1), "%d-%m-%Y", "01-06-2024")
|
||||
]
|
||||
|
||||
def test_datetime_to_string(self):
|
||||
"""Test converting a datetime to string."""
|
||||
for value, date_format, expected in self.test_cases:
|
||||
with self.subTest(value=value, date_format=date_format):
|
||||
retval = self.node.f(value=value, date_format=date_format)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value} with format={date_format}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_float_to_string import PyFloatToString
|
||||
|
||||
class TestPyFloatToString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyFloatToString()
|
||||
self.test_cases = [
|
||||
(3.14, "3.14"),
|
||||
(2.71, "2.71"),
|
||||
(0.577, "0.577"),
|
||||
(1.618, "1.618")
|
||||
]
|
||||
|
||||
def test_float_to_string(self):
|
||||
"""Test converting a float to string."""
|
||||
for value, expected in self.test_cases:
|
||||
with self.subTest(value=value):
|
||||
retval = self.node.f(value=value)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_int_to_string import PyIntToString
|
||||
|
||||
class TestPyIntToString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyIntToString()
|
||||
self.test_cases = [
|
||||
(3, "3"),
|
||||
(27, "27"),
|
||||
(100, "100"),
|
||||
(-42, "-42")
|
||||
]
|
||||
|
||||
def test_int_to_string(self):
|
||||
"""Test converting an integer to string."""
|
||||
for value, expected in self.test_cases:
|
||||
with self.subTest(value=value):
|
||||
retval = self.node.f(value=value)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_string_to_datetime import PyStringToDatetime
|
||||
|
||||
class TestPyStringToDatetime(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyStringToDatetime()
|
||||
self.test_cases = [
|
||||
("2023-03-15 12:00:00", "%Y-%m-%d %H:%M:%S", datetime(2023, 3, 15, 12, 0, 0)),
|
||||
("2024-06-01 09:30:00", "%Y-%m-%d %H:%M:%S", datetime(2024, 6, 1, 9, 30, 0)),
|
||||
("15/03/2023 12:00", "%d/%m/%Y %H:%M", datetime(2023, 3, 15, 12, 0)),
|
||||
("01-06-2024", "%d-%m-%Y", datetime(2024, 6, 1))
|
||||
]
|
||||
|
||||
def test_string_to_datetime(self):
|
||||
"""Test converting a string to datetime."""
|
||||
for value, date_format, expected in self.test_cases:
|
||||
with self.subTest(value=value, date_format=date_format):
|
||||
retval = self.node.f(value=value, date_format=date_format)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value} with format={date_format}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_string_to_float import PyStringToFloat
|
||||
|
||||
class TestPyStringToFloat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyStringToFloat()
|
||||
self.test_cases = [
|
||||
("3.14", 3.14),
|
||||
("2.71", 2.71),
|
||||
("0.577", 0.577),
|
||||
("1.618", 1.618)
|
||||
]
|
||||
|
||||
def test_string_to_float(self):
|
||||
"""Test converting a string to float."""
|
||||
for value, expected in self.test_cases:
|
||||
with self.subTest(value=value):
|
||||
retval = self.node.f(value=value)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from cda.py_string_to_int import PyStringToInt
|
||||
|
||||
class TestPyStringToInt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PyStringToInt()
|
||||
self.test_cases = [
|
||||
("3", 3),
|
||||
("27", 27),
|
||||
("100", 100),
|
||||
("-42", -42)
|
||||
]
|
||||
|
||||
def test_string_to_int(self):
|
||||
"""Test converting a string to int."""
|
||||
for value, expected in self.test_cases:
|
||||
with self.subTest(value=value):
|
||||
retval = self.node.f(value=value)[0]
|
||||
self.assertEqual(retval, expected, f"Mismatch for value={value}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,69 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_datetime import PandasAtDatetime
|
||||
|
||||
class TestPandasAtDatetime(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtDatetime()
|
||||
self.test_cases = [
|
||||
# Test with datetime values and string indices
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2023, 3, 15, 12, 0, 0)]}, index=["row1"]),
|
||||
"row1", "string", "a", "string",
|
||||
(datetime(2023, 3, 15, 12, 0, 0),)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2024, 6, 1, 9, 30, 0)]}, index=["row2"]),
|
||||
"row2", "string", "a", "string",
|
||||
(datetime(2024, 6, 1, 9, 30, 0),)
|
||||
),
|
||||
|
||||
# Test with integer indices
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2025, 1, 1, 0, 0, 0)]}, index=[0]),
|
||||
"0", "int", "a", "string",
|
||||
(datetime(2025, 1, 1, 0, 0, 0),)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2022, 12, 31, 23, 59, 59)]}, index=[1]),
|
||||
"1", "int", "a", "string",
|
||||
(datetime(2022, 12, 31, 23, 59, 59),)
|
||||
),
|
||||
|
||||
# Test with integer column labels
|
||||
(
|
||||
pd.DataFrame({1: [datetime(2020, 2, 29, 14, 15, 16)]}, index=[0]),
|
||||
"0", "int", 1, "int",
|
||||
(datetime(2020, 2, 29, 14, 15, 16),)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [datetime(2019, 7, 4, 18, 45, 30)]}, index=[1]),
|
||||
"1", "int", 2, "int",
|
||||
(datetime(2019, 7, 4, 18, 45, 30),)
|
||||
),
|
||||
|
||||
# Mixed types: string index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [datetime(2018, 11, 11, 11, 11, 11)]}, index=["event"]),
|
||||
"event", "string", 1, "int",
|
||||
(datetime(2018, 11, 11, 11, 11, 11),)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_datetime_cell(self):
|
||||
"""Test selecting a datetime cell from a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_float import PandasAtFloat
|
||||
|
||||
class TestPandasAtFloat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtFloat()
|
||||
self.test_cases = [
|
||||
# Test with float values and string indices
|
||||
(
|
||||
pd.DataFrame({"a": [123.456]}, index=["row1"]),
|
||||
"row1", "string", "a", "string",
|
||||
(123.456,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [789.101]}, index=["row2"]),
|
||||
"row2", "string", "a", "string",
|
||||
(789.101,)
|
||||
),
|
||||
|
||||
# Test with integer indices
|
||||
(
|
||||
pd.DataFrame({"a": [456.789]}, index=[0]),
|
||||
"0", "int", "a", "string",
|
||||
(456.789,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [987.654]}, index=[1]),
|
||||
"1", "int", "a", "string",
|
||||
(987.654,)
|
||||
),
|
||||
|
||||
# Test with integer column labels
|
||||
(
|
||||
pd.DataFrame({1: [321.654]}, index=[0]),
|
||||
"0", "int", 1, "int",
|
||||
(321.654,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [654.321]}, index=[1]),
|
||||
"1", "int", 2, "int",
|
||||
(654.321,)
|
||||
),
|
||||
|
||||
# Mixed types: string index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [111.222]}, index=["event"]),
|
||||
"event", "string", 1, "int",
|
||||
(111.222,)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_float_cell(self):
|
||||
"""Test selecting a float cell from a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_int import PandasAtInt
|
||||
|
||||
class TestPandasAtInt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtInt()
|
||||
self.test_cases = [
|
||||
# Test with integer values and string indices
|
||||
(
|
||||
pd.DataFrame({"a": [123]}, index=["row1"]),
|
||||
"row1", "string", "a", "string",
|
||||
(123,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [789]}, index=["row2"]),
|
||||
"row2", "string", "a", "string",
|
||||
(789,)
|
||||
),
|
||||
|
||||
# Test with integer indices
|
||||
(
|
||||
pd.DataFrame({"a": [456]}, index=[0]),
|
||||
"0", "int", "a", "string",
|
||||
(456,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [987]}, index=[1]),
|
||||
"1", "int", "a", "string",
|
||||
(987,)
|
||||
),
|
||||
|
||||
# Test with integer column labels
|
||||
(
|
||||
pd.DataFrame({1: [321]}, index=[0]),
|
||||
"0", "int", 1, "int",
|
||||
(321,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [654]}, index=[1]),
|
||||
"1", "int", 2, "int",
|
||||
(654,)
|
||||
),
|
||||
|
||||
# Mixed types: string index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [111]}, index=["event"]),
|
||||
"event", "string", 1, "int",
|
||||
(111,)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_int_cell(self):
|
||||
"""Test selecting an integer cell from a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,62 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_set_datetime import PandasAtSetDatetime
|
||||
|
||||
class TestPandasAtSetDatetime(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtSetDatetime()
|
||||
self.test_cases = [
|
||||
# Test with string row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row1"]),
|
||||
"row1", "string", "a", "string", datetime(2023, 3, 15, 12, 0, 0)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row2"]),
|
||||
"row2", "string", "a", "string", datetime(2024, 6, 1, 9, 30, 0)
|
||||
),
|
||||
# Test with integer row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[0]),
|
||||
"0", "int", "a", "string", datetime(2025, 1, 1, 0, 0, 0)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[1]),
|
||||
"1", "int", "a", "string", datetime(2022, 12, 31, 23, 59, 59)
|
||||
),
|
||||
# Test with integer row index and integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=[0]),
|
||||
"0", "int", 1, "int", datetime(2020, 2, 29, 14, 15, 16)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [None]}, index=[1]),
|
||||
"1", "int", 2, "int", datetime(2019, 7, 4, 18, 45, 30)
|
||||
),
|
||||
# Mixed types: string row index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=["event"]),
|
||||
"event", "string", 1, "int", datetime(2018, 11, 11, 11, 11, 11)
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_datetime_cell(self):
|
||||
"""Test setting a datetime cell in a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type, data)
|
||||
self.assertEqual(retval[0].at[int(row_index) if row_index_type == "int" else row_index,
|
||||
int(column_label) if column_label_type == "int" else column_label],
|
||||
data,
|
||||
f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_set_float import PandasAtSetFloat
|
||||
|
||||
class TestPandasAtSetFloat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtSetFloat()
|
||||
self.test_cases = [
|
||||
# Test with string row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row1"]),
|
||||
"row1", "string", "a", "string", 3.14
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row2"]),
|
||||
"row2", "string", "a", "string", 2.71
|
||||
),
|
||||
# Test with integer row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[0]),
|
||||
"0", "int", "a", "string", 1.618
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[1]),
|
||||
"1", "int", "a", "string", 0.577
|
||||
),
|
||||
# Test with integer row index and integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=[0]),
|
||||
"0", "int", 1, "int", 6.28
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [None]}, index=[1]),
|
||||
"1", "int", 2, "int", 1.414
|
||||
),
|
||||
# Mixed types: string row index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=["event"]),
|
||||
"event", "string", 1, "int", 2.236
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_float_cell(self):
|
||||
"""Test setting a float cell in a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type, data)
|
||||
self.assertEqual(retval[0].at[int(row_index) if row_index_type == "int" else row_index,
|
||||
int(column_label) if column_label_type == "int" else column_label],
|
||||
data,
|
||||
f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_set_int import PandasAtSetInt
|
||||
|
||||
class TestPandasAtSetInt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtSetInt()
|
||||
self.test_cases = [
|
||||
# Test with string row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row1"]),
|
||||
"row1", "string", "a", "string", 10
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row2"]),
|
||||
"row2", "string", "a", "string", 20
|
||||
),
|
||||
# Test with integer row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[0]),
|
||||
"0", "int", "a", "string", 30
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[1]),
|
||||
"1", "int", "a", "string", 40
|
||||
),
|
||||
# Test with integer row index and integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=[0]),
|
||||
"0", "int", 1, "int", 50
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [None]}, index=[1]),
|
||||
"1", "int", 2, "int", 60
|
||||
),
|
||||
# Mixed types: string row index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=["event"]),
|
||||
"event", "string", 1, "int", 70
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_int_cell(self):
|
||||
"""Test setting an integer cell in a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type, data)
|
||||
self.assertEqual(retval[0].at[int(row_index) if row_index_type == "int" else row_index,
|
||||
int(column_label) if column_label_type == "int" else column_label],
|
||||
data,
|
||||
f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_set_string import PandasAtSetString
|
||||
|
||||
class TestPandasAtSetString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtSetString()
|
||||
self.test_cases = [
|
||||
# Test with string row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row1"]),
|
||||
"row1", "string", "a", "string", "hello"
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=["row2"]),
|
||||
"row2", "string", "a", "string", "world"
|
||||
),
|
||||
# Test with integer row index and string column label
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[0]),
|
||||
"0", "int", "a", "string", "foo"
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [None]}, index=[1]),
|
||||
"1", "int", "a", "string", "bar"
|
||||
),
|
||||
# Test with integer row index and integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=[0]),
|
||||
"0", "int", 1, "int", "baz"
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: [None]}, index=[1]),
|
||||
"1", "int", 2, "int", "qux"
|
||||
),
|
||||
# Mixed types: string row index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: [None]}, index=["event"]),
|
||||
"event", "string", 1, "int", "alpha"
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_string_cell(self):
|
||||
"""Test setting a string cell in a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type, data)
|
||||
self.assertEqual(retval[0].at[int(row_index) if row_index_type == "int" else row_index,
|
||||
int(column_label) if column_label_type == "int" else column_label],
|
||||
data,
|
||||
f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_at_string import PandasAtString
|
||||
|
||||
class TestPandasAtString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasAtString()
|
||||
self.test_cases = [
|
||||
# Test with string values and string indices
|
||||
(
|
||||
pd.DataFrame({"a": ["apple"]}, index=["row1"]),
|
||||
"row1", "string", "a", "string",
|
||||
("apple",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": ["banana"]}, index=["row2"]),
|
||||
"row2", "string", "a", "string",
|
||||
("banana",)
|
||||
),
|
||||
|
||||
# Test with integer indices
|
||||
(
|
||||
pd.DataFrame({"a": ["cherry"]}, index=[0]),
|
||||
"0", "int", "a", "string",
|
||||
("cherry",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": ["date"]}, index=[1]),
|
||||
"1", "int", "a", "string",
|
||||
("date",)
|
||||
),
|
||||
|
||||
# Test with integer column labels
|
||||
(
|
||||
pd.DataFrame({1: ["elderberry"]}, index=[0]),
|
||||
"0", "int", 1, "int",
|
||||
("elderberry",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: ["fig"]}, index=[1]),
|
||||
"1", "int", 2, "int",
|
||||
("fig",)
|
||||
),
|
||||
|
||||
# Mixed types: string index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: ["grape"]}, index=["event"]),
|
||||
"event", "string", 1, "int",
|
||||
("grape",)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_string_cell(self):
|
||||
"""Test selecting a string cell from a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,55 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_datetime import PandasIatDatetime
|
||||
|
||||
class TestPandasIatDatetime(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatDatetime()
|
||||
self.test_cases = [
|
||||
# Test with datetime values
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2023, 3, 15, 12, 0, 0)]}),
|
||||
0, 0,
|
||||
(datetime(2023, 3, 15, 12, 0, 0),)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [datetime(2024, 6, 1, 9, 30, 0)]}),
|
||||
0, 0,
|
||||
(datetime(2024, 6, 1, 9, 30, 0),)
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame({
|
||||
"a": [datetime(2025, 1, 1, 0, 0, 0), datetime(2022, 12, 31, 23, 59, 59)],
|
||||
"b": [datetime(2020, 2, 29, 14, 15, 16), datetime(2019, 7, 4, 18, 45, 30)]
|
||||
}),
|
||||
1, 1,
|
||||
(datetime(2019, 7, 4, 18, 45, 30),)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({
|
||||
1: [datetime(2018, 11, 11, 11, 11, 11)],
|
||||
2: [datetime(2017, 5, 23, 6, 30, 0)]
|
||||
}),
|
||||
0, 1,
|
||||
(datetime(2017, 5, 23, 6, 30, 0),)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_datetime_cell(self):
|
||||
"""Test selecting a datetime cell from a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_float import PandasIatFloat
|
||||
|
||||
class TestPandasIatFloat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatFloat()
|
||||
self.test_cases = [
|
||||
# Test with float values
|
||||
(
|
||||
pd.DataFrame({"a": [1.23]}),
|
||||
0, 0,
|
||||
(1.23,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [4.56]}),
|
||||
0, 0,
|
||||
(4.56,)
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame({
|
||||
"a": [7.89, 3.21],
|
||||
"b": [6.54, 9.87]
|
||||
}),
|
||||
1, 1,
|
||||
(9.87,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({
|
||||
1: [2.34],
|
||||
2: [5.67]
|
||||
}),
|
||||
0, 1,
|
||||
(5.67,)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_float_cell(self):
|
||||
"""Test selecting a float cell from a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_int import PandasIatInt
|
||||
|
||||
class TestPandasIatInt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatInt()
|
||||
self.test_cases = [
|
||||
# Test with integer values
|
||||
(
|
||||
pd.DataFrame({"a": [123]}),
|
||||
0, 0,
|
||||
(123,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": [456]}),
|
||||
0, 0,
|
||||
(456,)
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame({
|
||||
"a": [789, 321],
|
||||
"b": [654, 987]
|
||||
}),
|
||||
1, 1,
|
||||
(987,)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({
|
||||
1: [234],
|
||||
2: [567]
|
||||
}),
|
||||
0, 1,
|
||||
(567,)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_int_cell(self):
|
||||
"""Test selecting an integer cell from a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,47 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_set_datetime import PandasIatSetDatetime
|
||||
|
||||
class TestPandasIatSetDatetime(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatSetDatetime()
|
||||
self.test_cases = [
|
||||
# Test with datetime values
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, datetime(2023, 3, 15, 12, 0, 0)
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, datetime(2024, 6, 1, 9, 30, 0)
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame([[None, None], [None, None]]),
|
||||
1, 1, datetime(2019, 7, 4, 18, 45, 30)
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None, None]]),
|
||||
0, 1, datetime(2018, 11, 11, 11, 11, 11)
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_datetime_cell(self):
|
||||
"""Test setting a datetime cell in a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos, data)
|
||||
self.assertEqual(retval[0].iat[row_pos, col_pos],
|
||||
data,
|
||||
f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_set_float import PandasIatSetFloat
|
||||
|
||||
class TestPandasIatSetFloat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatSetFloat()
|
||||
self.test_cases = [
|
||||
# Test with float values
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, 3.14
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, 2.71
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame([[None, None], [None, None]]),
|
||||
1, 1, 1.618
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None, None]]),
|
||||
0, 1, 0.577
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_float_cell(self):
|
||||
"""Test setting a float cell in a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos, data)
|
||||
self.assertEqual(retval[0].iat[row_pos, col_pos],
|
||||
data,
|
||||
f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_set_int import PandasIatSetInt
|
||||
|
||||
class TestPandasIatSetInt(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatSetInt()
|
||||
self.test_cases = [
|
||||
# Test with integer values
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, 10
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, 20
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame([[None, None], [None, None]]),
|
||||
1, 1, 30
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None, None]]),
|
||||
0, 1, 40
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_int_cell(self):
|
||||
"""Test setting an integer cell in a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos, data)
|
||||
self.assertEqual(retval[0].iat[row_pos, col_pos],
|
||||
data,
|
||||
f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_set_string import PandasIatSetString
|
||||
|
||||
class TestPandasIatSetString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatSetString()
|
||||
self.test_cases = [
|
||||
# Test with string values
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, "hello"
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None]]),
|
||||
0, 0, "world"
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame([[None, None], [None, None]]),
|
||||
1, 1, "foo"
|
||||
),
|
||||
(
|
||||
pd.DataFrame([[None, None]]),
|
||||
0, 1, "bar"
|
||||
),
|
||||
]
|
||||
|
||||
def test_set_string_cell(self):
|
||||
"""Test setting a string cell in a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, data in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos, data)
|
||||
self.assertEqual(retval[0].iat[row_pos, col_pos],
|
||||
data,
|
||||
f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_iat_string import PandasIatString
|
||||
|
||||
class TestPandasIatString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasIatString()
|
||||
self.test_cases = [
|
||||
# Test with string values
|
||||
(
|
||||
pd.DataFrame({"a": ["hello"]}),
|
||||
0, 0,
|
||||
("hello",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": ["world"]}),
|
||||
0, 0,
|
||||
("world",)
|
||||
),
|
||||
# Test with multiple rows and columns
|
||||
(
|
||||
pd.DataFrame({
|
||||
"a": ["foo", "bar"],
|
||||
"b": ["baz", "qux"]
|
||||
}),
|
||||
1, 1,
|
||||
("qux",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({
|
||||
1: ["alpha"],
|
||||
2: ["beta"]
|
||||
}),
|
||||
0, 1,
|
||||
("beta",)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_string_cell(self):
|
||||
"""Test selecting a string cell from a pandas DataFrame."""
|
||||
for dataframe, row_pos, col_pos, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_pos=row_pos, col_pos=col_pos):
|
||||
retval = self.node.f(dataframe, row_pos, col_pos)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_pos={row_pos}, col_pos={col_pos}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,68 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pandas as pd
|
||||
|
||||
PROJECT_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||
MODULE_ROOT = os.path.join(PROJECT_ROOT, "modules")
|
||||
sys.path.append(MODULE_ROOT)
|
||||
from pandas_wrapper.pandas_loc_cell_string import PandasLocCellString
|
||||
|
||||
class TestPandasAtString(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data."""
|
||||
self.node = PandasLocCellString()
|
||||
self.test_cases = [
|
||||
# Test with string values and string indices
|
||||
(
|
||||
pd.DataFrame({"a": ["apple"]}, index=["row1"]),
|
||||
"row1", "string", "a", "string",
|
||||
("apple",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": ["banana"]}, index=["row2"]),
|
||||
"row2", "string", "a", "string",
|
||||
("banana",)
|
||||
),
|
||||
|
||||
# Test with integer indices
|
||||
(
|
||||
pd.DataFrame({"a": ["cherry"]}, index=[0]),
|
||||
"0", "int", "a", "string",
|
||||
("cherry",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({"a": ["date"]}, index=[1]),
|
||||
"1", "int", "a", "string",
|
||||
("date",)
|
||||
),
|
||||
|
||||
# Test with integer column labels
|
||||
(
|
||||
pd.DataFrame({1: ["elderberry"]}, index=[0]),
|
||||
"0", "int", 1, "int",
|
||||
("elderberry",)
|
||||
),
|
||||
(
|
||||
pd.DataFrame({2: ["fig"]}, index=[1]),
|
||||
"1", "int", 2, "int",
|
||||
("fig",)
|
||||
),
|
||||
|
||||
# Mixed types: string index, integer column label
|
||||
(
|
||||
pd.DataFrame({1: ["grape"]}, index=["event"]),
|
||||
"event", "string", 1, "int",
|
||||
("grape",)
|
||||
),
|
||||
]
|
||||
|
||||
def test_select_string_cell(self):
|
||||
"""Test selecting a string cell from a pandas DataFrame."""
|
||||
for dataframe, row_index, row_index_type, column_label, column_label_type, expected in self.test_cases:
|
||||
with self.subTest(dataframe=dataframe, row_index=row_index, column_label=column_label):
|
||||
retval = self.node.f(dataframe, row_index, row_index_type, column_label, column_label_type)
|
||||
self.assertEqual(retval, expected, f"Mismatch for row_index={row_index}, column_label={column_label}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -55,7 +55,7 @@ class TestPtEvaluate(unittest.TestCase):
|
||||
epochs = 1
|
||||
self.loaded_model = self.load_model.f(self.model, f"fashion_mnist_{epochs}_epochs_conv.pt")
|
||||
|
||||
# Instntiates evaluation node
|
||||
# Instantiates evaluation node
|
||||
self.evaluate = PtEvaluateClassificationModel()
|
||||
|
||||
def test_evaluation(self):
|
||||
|
||||
Reference in New Issue
Block a user