Added Pandas Exp, Log, Sin, Cos, Tan nodes and updated Pandas DataFrame Summary node to output a DataFrame instead of a string. Added node reference pages.

This commit is contained in:
HowToSD
2025-02-18 16:45:39 -08:00
parent e63b1e54ce
commit 27533783ad
134 changed files with 1802 additions and 118 deletions
+4 -2
View File
@@ -3,8 +3,10 @@ import json
class CDAJSONCreate:
"""
CDAJSONCreate:
A class for creating a serialized JSON object using values entered in the text field.
CDA JSON Create:
Creates a serialized JSON object using values entered in the text field.
category: IO
"""
@classmethod
+4 -2
View File
@@ -7,8 +7,10 @@ from .util import plot_post_steps
class MPLBar:
"""
MPLBar:
A class for generating bar charts from a pandas DataFrame.
MPL Bar Chart:
Generates a bar chart from a Pandas DataFrame.
category: Plot
"""
@classmethod
+4 -2
View File
@@ -7,8 +7,10 @@ from .util import plot_post_steps
class MPLLine:
"""
MPLPlotLine:
A class for generating line plots from a pandas DataFrame.
MPL Line Plot:
Generates a line plot from a pandas DataFrame.
category: Plot
"""
@classmethod
+4 -2
View File
@@ -7,8 +7,10 @@ from .util import plot_post_steps
class MPLScatter:
"""
MPLPlotScatter:
A class for generating scatter plots from a pandas DataFrame.
MPL Scatter Plot:
Generates a scatter plot from a pandas DataFrame.
category: Plot
"""
@classmethod
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasAdd:
"""
PandasAdd:
A class for adding two pandas DataFrames.
Adds two pandas DataFrames.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -3,8 +3,9 @@ import pandas as pd
class PandasAddSeries:
"""
PandasAdd:
A class for adding a Pandas Series to a pandas DataFrames.
Adds a Pandas Series to a pandas DataFrames.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasAsFloat:
"""
PandasAsFloat:
A class for converting all cells in a pandas DataFrame to float type.
Converts all cells in a pandas DataFrame to float type.
category: Data type conversion
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasAsInt:
"""
PandasAsInt:
A class for converting all cells in a pandas DataFrame to integer type.
Converts all cells in a pandas DataFrame to integer type.
category: Data type conversion
"""
@classmethod
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasAsString:
"""
PandasAsString:
A class for converting all cells in a pandas DataFrame to string type.
Converts all cells in a pandas DataFrame to string type.
category: Data type conversion
"""
@classmethod
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasColumns:
"""
PandasColumns:
A class for retrieving the column labels of a pandas DataFrame.
Retrieves the column labels of a pandas DataFrame.
category: DataFrame information
"""
@classmethod
+46
View File
@@ -0,0 +1,46 @@
from typing import Any, Dict
import pandas as pd
import numpy as np
class PandasCos:
"""
Apply the cosine function to a pandas DataFrame and converting non-numeric values to NaN.
category: Math
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Converts non-numeric values to NaN and applies the cosine function to the DataFrame.
The cosine function returns the ratio of the adjacent side to the hypotenuse in a right triangle,
or equivalently, the x-coordinate of a point on the unit circle.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the processed DataFrame.
"""
dataframe = dataframe.apply(pd.to_numeric, errors='coerce')
dataframe = np.cos(dataframe)
return (dataframe,)
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasCount:
"""
PandasCount:
A class for computing the count of a pandas DataFrame.
Computes the count of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasCreate:
"""
PandasCreate:
A class for creating a pandas DataFrame using values entered in the text field.
Creates a pandas DataFrame using values entered in the text field.
category: IO
"""
@classmethod
@@ -5,9 +5,9 @@ import pandas as pd
class PandasCreateWithIndex:
"""
PandasCreateWithIndex:
A class for creating a pandas DataFrame using values entered in the text field.
Input data is assume to have an index.
Creates a pandas DataFrame using values entered in the text field. Input data is assumed to have an index.
category: IO
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasDiv:
"""
PandasDiv:
A class for dividing two pandas DataFrames.
Divides two pandas DataFrames.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import jsons_to_series
class PandasDivSeries:
"""
PandasDivSeries:
A class for dividing a Pandas DataFrame by a Pandas Series.
Divides a Pandas DataFrame by a Pandas Series.
category: Arithmetic method
"""
@classmethod
+4 -2
View File
@@ -3,8 +3,10 @@ import pandas as pd
class PandasDropNA:
"""
PandasColumns:
A class for droping missing values from a pandas DataFrame.
Pandas Drop NA:
Drops missing values from a pandas DataFrame.
category: Data cleansing
"""
@classmethod
+43
View File
@@ -0,0 +1,43 @@
from typing import Any, Dict
import pandas as pd
import numpy as np
class PandasExp:
"""
Apply the exponential function to a pandas DataFrame and converting non-numeric values to NaN.
category: Math
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Converts non-numeric values to NaN and applies the exponential function to the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the processed DataFrame.
"""
dataframe = dataframe.apply(pd.to_numeric, errors='coerce')
dataframe = np.exp(dataframe)
return (dataframe,)
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasGroupBy:
"""
PandasGroupBy:
A class for computing aggregate values for groups in a DataFrame.
Computes aggregate values for groups in a DataFrame.
category: Aggregation
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasHead:
"""
PandasHead:
A class for retrieving the first few rows of a pandas DataFrame.
Retrieves the first few rows of a pandas DataFrame.
category: Data subset selection
"""
@classmethod
@@ -4,8 +4,9 @@ import pandas as pd
class PandasHorizontalConcat:
"""
PandasHorizontalConcat:
A class for horizontally concatenating two pandas DataFrames.
Horizontally concatenates two pandas DataFrames.
category: Transformation
"""
@classmethod
@@ -5,10 +5,11 @@ from .utils import series_to_jsons
class PandasIlocRowSeries:
"""
PandasLocRowSeries:
A class for selecting a row from a pandas DataFrame and returning it as a Series.
The row is specified by its integer position, similar to an index in other software.
Note: In Pandas, "index" refers to a unique label assigned to each row. See https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html
Selects a row from a pandas DataFrame and returning it as a Series.
The row is specified by its integer position, similar to an index in other software.
Note: In Pandas, "index" refers to a unique label assigned to each row. See https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html
category: Data subset selection
"""
@classmethod
@@ -6,9 +6,10 @@ from .utils import series_to_jsons
class PandasIlocRowsDataFrame:
"""
PandasIlocRowsDataFrame:
A class for selecting rows from a pandas DataFrame and returning it as a DataFrame.
Rows are specified by the list of integer positions.
Selects rows from a pandas DataFrame and returning it as a DataFrame.
Rows are specified by the list of integer positions.
category: Data subset selection
"""
@classmethod
+3 -2
View File
@@ -3,8 +3,9 @@ import pandas as pd
class PandasIndex:
"""
PandasColumns:
A class for retrieving the row labels (index) of a pandas DataFrame.
Retrieves the row labels (index) of a pandas DataFrame.
category: DataFrame information
"""
@classmethod
@@ -4,8 +4,9 @@ import pandas as pd
class PandasIndexToString:
"""
PandasIndexToString:
A class for converting a pandas Index to a string representation.
Converts a pandas Index to a string representation.
category: Display data
"""
@classmethod
+4 -2
View File
@@ -4,8 +4,10 @@ import pandas as pd
class PandasIsNA:
"""
PandasColumns:
A class for checking a pandas DataFrame for missing values.
Pandas Is NA:
Checks a pandas DataFrame for missing values.
category: Data cleansing
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasJoin:
"""
PandasJoin:
A class for merging two pandas DataFrames based on a common column.
Merges two pandas DataFrames based on a common column.
category: Transformation
"""
@classmethod
+4 -2
View File
@@ -5,8 +5,10 @@ import pandas as pd
class PandasLoadCSV:
"""
PandasLoadCSV:
A class for loading CSV files into a pandas DataFrame.
Pandas Load CSV:
Loads CSV files into a pandas DataFrame.
category: IO
"""
@classmethod
@@ -5,8 +5,10 @@ import pandas as pd
class PandasLoadCSVWithEncoding:
"""
PandasLoadCSVWithEncoding:
A class for loading CSV files into a pandas DataFrame.
Pandas Load CSV With Encoding:
Loads CSV files into a pandas DataFrame.
category: IO
"""
@classmethod
@@ -5,9 +5,11 @@ import pandas as pd
class PandasLoadCSVWithIndex:
"""
PandasLoadCSV:
A class for loading CSV files into a pandas DataFrame.
Input data is assume to have an index.
Pandas Load CSV With Index:
Loads CSV files into a pandas DataFrame.
Input data is assume to have an index.
category: IO
"""
@classmethod
+4 -2
View File
@@ -5,8 +5,10 @@ import pandas as pd
class PandasLoadJSON:
"""
PandasLoadJSON:
A class for loading JSON files into a pandas DataFrame.
Pandas Load JSON:
Loads JSON files into a pandas DataFrame.
category: IO
"""
@classmethod
@@ -4,8 +4,9 @@ import pandas as pd
class PandasLocCellStr:
"""
PandasLocCellStr:
A class for selecting a cell from a pandas DataFrame and output as a string.
Selects a cell from a pandas DataFrame and output as a string.
category: Data subset selection
"""
@classmethod
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasLocRowSeries:
"""
PandasLocRowSeries:
A class for selecting a row from a pandas DataFrame and output as a Series.
Selects a row from a pandas DataFrame and output as a Series.
category: Data subset selection
"""
@classmethod
+43
View File
@@ -0,0 +1,43 @@
from typing import Any, Dict
import pandas as pd
import numpy as np
class PandasLog:
"""
Applying the natural logarithm function to a pandas DataFrame and converting non-numeric values to NaN.
category: Math
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Converts non-numeric values to NaN and applies the natural logarithm function to the DataFrame.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the processed DataFrame.
"""
dataframe = dataframe.apply(pd.to_numeric, errors='coerce')
dataframe = np.log(dataframe)
return (dataframe,)
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasMax:
"""
PandasMin:
A class for computing the max of a pandas DataFrame.
Computes the max of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasMean:
"""
PandasMin:
A class for computing the mean of a pandas DataFrame.
Computes the mean of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasMedian:
"""
PandasMin:
A class for computing the median of a pandas DataFrame.
Computes the median of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasMin:
"""
PandasMin:
A class for computing the min of a pandas DataFrame.
Computes the min of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasMode:
"""
PandasMode:
A class for computing the mode of a pandas DataFrame.
Computes the mode of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasMul:
"""
PandasMul:
A class for multiplying two pandas DataFrames.
Multiplies two pandas DataFrames.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import jsons_to_series
class PandasMulSeries:
"""
PandasMulSeries:
A class for multiplying a Pandas DataFrame by a Pandas Series.
Multiplies a Pandas DataFrame by a Pandas Series.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasPow:
"""
PandasPow:
A class for exponentiating two pandas DataFrames.
Exponentiates two pandas DataFrames.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import jsons_to_series
class PandasPowSeries:
"""
PandasPowSeries:
A class for raising a Pandas DataFrame to the power of a Pandas Series.
Raises a Pandas DataFrame to the power of a Pandas Series.
category: Arithmetic method
"""
@classmethod
+4 -2
View File
@@ -10,8 +10,10 @@ import pandas as pd
class PandasSaveCSV:
"""
PandasSaveCSV:
A class for saving a PandasDataFrame to a CSV file.
Pandas Save CSV:
Saves a PandasDataFrame to a CSV file.
category: IO
"""
@classmethod
def INPUT_TYPES(s):
+4 -2
View File
@@ -10,8 +10,10 @@ import pandas as pd
class PandasSaveJSON:
"""
PandasSaveJSON:
A class for saving a PandasDataFrame to a JSON file.
Pandas Save JSON:
Saves a PandasDataFrame to a JSON file.
category: IO
"""
@classmethod
def INPUT_TYPES(s):
@@ -4,8 +4,9 @@ import pandas as pd
class PandasSelectColumns:
"""
PandasSelectColumns:
A class for selecting specific columns from a pandas DataFrame.
Selects specific columns from a pandas DataFrame.
category: Data subset selection
"""
@classmethod
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasSelectRows:
"""
PandasSelectRows:
A class for selecting specific rows from a pandas DataFrame based on a condition.
Selects specific rows from a pandas DataFrame based on a condition.
category: Data subset selection
"""
@classmethod
@@ -5,8 +5,9 @@ from .utils import jsons_to_series
class PandasSeriesToString:
"""
PandasSeriesToString:
A class for converting a pandas Series to a string representation.
Converts a pandas Series to a string representation.
category: Display data
"""
@classmethod
@@ -8,6 +8,11 @@ from io import StringIO
import pandas as pd
class PandasShowDataFrame:
"""
Displays a Pandas DataFrame as text.
category: Display data
"""
@classmethod
def INPUT_TYPES(s):
return {
@@ -7,6 +7,11 @@ See credit/credit.md for the full license.
import pandas as pd
class PandasShowIndex:
"""
Displays a Pandas Index as text.
category: Display data
"""
@classmethod
def INPUT_TYPES(s):
return {
@@ -10,6 +10,11 @@ from .utils import series_to_jsons
from .utils import jsons_to_series
class PandasShowSeries:
"""
Displays a Pandas Series as text.
category: Display data
"""
@classmethod
def INPUT_TYPES(s):
return {
@@ -6,6 +6,11 @@ See credit/credit.md for the full license.
"""
class PandasShowText:
"""
Displays a string.
category: Display data
"""
@classmethod
def INPUT_TYPES(s):
return {
+46
View File
@@ -0,0 +1,46 @@
from typing import Any, Dict
import pandas as pd
import numpy as np
class PandasSin:
"""
Applies the sine function to a pandas DataFrame and converting non-numeric values to NaN.
category: Math
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Converts non-numeric values to NaN and applies the sine function to the DataFrame.
The sine function returns the ratio of the opposite side to the hypotenuse in a right triangle,
or equivalently, the y-coordinate of a point on the unit circle.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the processed DataFrame.
"""
dataframe = dataframe.apply(pd.to_numeric, errors='coerce')
dataframe = np.sin(dataframe)
return (dataframe,)
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasSort:
"""
PandasSort:
A class for sorting a pandas DataFrame by a specified column.
Sorts a pandas DataFrame by a specified column.
category: Transformation
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasStd:
"""
PandasStd:
A class for computing the standard deviation of a pandas DataFrame.
Computes the standard deviation of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+4 -3
View File
@@ -5,8 +5,9 @@ import pandas as pd
class PandasSub:
"""
PandasSub:
A class for subtracting two pandas DataFrames.
Subtracts a Pandas DataFrame from another DataFrame.
category: Arithmetic method
"""
@classmethod
@@ -30,7 +31,7 @@ class PandasSub:
def f(self, a_dataframe: pd.DataFrame, b_dataframe: pd.DataFrame) -> tuple:
"""
Subtract two pandas DataFrames.
Subtracts a Pandas DataFrame from another DataFrame.
Args:
a_dataframe (DataFrame): The left DataFrame.
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import jsons_to_series
class PandasSubSeries:
"""
PandasSubSeries:
A class for subtracting a Pandas Series from a Pandas DataFrame.
Subtracts a Pandas Series from a Pandas DataFrame.
category: Arithmetic method
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasSum:
"""
PandasSum:
A class for computing the sum of a pandas DataFrame.
Computes the sum of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
+5 -4
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasSummary:
"""
PandasSummary:
A class for analyzing and summarizing a pandas DataFrame.
Analyzes and summarizes a pandas DataFrame.
category: Summary statistics
"""
@classmethod
@@ -34,7 +35,7 @@ class PandasSummary:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing a string representation of the DataFrame summary.
tuple: A tuple containing the DataFrame summary.
"""
summary = dataframe.describe()
return (str(summary),)
return (summary,)
+46
View File
@@ -0,0 +1,46 @@
from typing import Any, Dict
import pandas as pd
import numpy as np
class PandasTan:
"""
Applies the tangent function to a pandas DataFrame and converting non-numeric values to NaN.
category: Math
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"dataframe": ("DATAFRAME", {})
}
}
RETURN_TYPES: tuple = ("DATAFRAME",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, dataframe: pd.DataFrame) -> tuple:
"""
Converts non-numeric values to NaN and applies the tangent function to the DataFrame.
The tangent function is the ratio of the sine to the cosine, representing the slope of a line
from the origin to a point on the unit circle.
Args:
dataframe (DataFrame): The DataFrame.
Returns:
tuple: A tuple containing the processed DataFrame.
"""
dataframe = dataframe.apply(pd.to_numeric, errors='coerce')
dataframe = np.tan(dataframe)
return (dataframe,)
+3 -2
View File
@@ -4,8 +4,9 @@ import pandas as pd
class PandasToString:
"""
PandasToString:
A class for converting a pandas DataFrame to a string representation.
Converts a pandas DataFrame to a string representation.
category: Display data
"""
@classmethod
+3 -2
View File
@@ -5,8 +5,9 @@ from .utils import series_to_jsons
class PandasVar:
"""
PandasVar:
A class for computing the variance of a pandas DataFrame.
Computes the variance of a pandas DataFrame.
category: Summary statistics
"""
@classmethod
@@ -4,8 +4,9 @@ import pandas as pd
class PandasVerticalConcat:
"""
PandasVerticalConcat:
A class for vertically concatenating two pandas DataFrames.
Vertically concatenates two pandas DataFrames.
category: Transformation
"""
@classmethod
+2
View File
@@ -69,6 +69,8 @@ class NpEncoder(json.JSONEncoder):
Source: https://stackoverflow.com/questions/50916422/python-typeerror-object-of-type-int64-is-not-json-serializable
Author: Jie Yang, Tommy
Licensed under CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
pragma: skip_doc
"""
def default(self, obj):
if isinstance(obj, np.integer):