Added Pandas Kurtosis & Pandas Skew nodes. Fixed docstrings for various nodes to address doc inaccuracies from v1.1.0 changes.
This commit is contained in:
@@ -30,13 +30,13 @@ class PandasCreate:
|
||||
|
||||
def create(self, data: str) -> tuple:
|
||||
"""
|
||||
Create a pandas DataFrame using values entered in the text field and converts it to a JSON string.
|
||||
Create a pandas DataFrame using values entered in the text field and converts it to a DataFrame.
|
||||
|
||||
Args:
|
||||
data (str): String value in the text field.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string representation of the DataFrame.
|
||||
tuple: A tuple containing a the DataFrame.
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(StringIO(data))
|
||||
|
||||
@@ -31,7 +31,7 @@ class PandasCreateWithIndex:
|
||||
|
||||
def create(self, data: str, index_col: int=0) -> tuple:
|
||||
"""
|
||||
Create a pandas DataFrame using values entered in the text field and converts it to a JSON string.
|
||||
Create a pandas DataFrame using values entered in the text field and converts it to a DataFrame.
|
||||
Input data is assume to have an index.
|
||||
|
||||
Args:
|
||||
@@ -39,7 +39,7 @@ class PandasCreateWithIndex:
|
||||
index_col (int): Position of the index column.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string representation of the DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
# Read CSV file into DataFrame
|
||||
df = pd.read_csv(StringIO(data), index_col=index_col)
|
||||
|
||||
@@ -37,7 +37,7 @@ class PandasCummax:
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the renamed DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
if axis=="index":
|
||||
df_out = dataframe.cummax(axis=0)
|
||||
|
||||
@@ -37,7 +37,7 @@ class PandasCummin:
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the renamed DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
if axis=="index":
|
||||
df_out = dataframe.cummin(axis=0)
|
||||
|
||||
@@ -37,7 +37,7 @@ class PandasCumprod:
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the renamed DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
if axis=="index":
|
||||
df_out = dataframe.cumprod(axis=0)
|
||||
|
||||
@@ -37,7 +37,7 @@ class PandasCumsum:
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the renamed DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
if axis=="index":
|
||||
df_out = dataframe.cumsum(axis=0)
|
||||
|
||||
@@ -44,7 +44,7 @@ class PandasGroupBy:
|
||||
aggregate_function (str): The type of aggregate function to perform.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the merged DataFrame.
|
||||
tuple: A tuple containing the merged DataFrame.
|
||||
"""
|
||||
if aggragate_function == "max":
|
||||
df_out = dataframe.groupby(column_name).max()
|
||||
|
||||
@@ -38,7 +38,7 @@ class PandasHead:
|
||||
rows (int): The number of rows to retrieve.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the resulting DataFrame.
|
||||
tuple: A tuple containing the resulting DataFrame.
|
||||
"""
|
||||
df2 = dataframe.head(rows)
|
||||
return (df2,)
|
||||
|
||||
@@ -43,8 +43,7 @@ class PandasIlocRowsDataFrame:
|
||||
row_int_pos_list_json (str): A list containing row integer positions.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the value of the row in string. The string is
|
||||
a JSON string containing the serialized Pandas Series object.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
row_int_pos_list = json.loads(row_int_pos_list_json)
|
||||
df2 = dataframe.iloc[row_int_pos_list]
|
||||
|
||||
@@ -42,7 +42,7 @@ class PandasJoin:
|
||||
join_method (str): The type of join to perform ("inner", "left", "right", "outer").
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the merged DataFrame.
|
||||
tuple: A tuple containing the merged DataFrame.
|
||||
"""
|
||||
df_out = pd.merge(left_dataframe, right_dataframe, on=on_column_name, how=join_method)
|
||||
return (df_out,)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasKurtosis:
|
||||
"""
|
||||
Computes the unbiased kurtosis of the DataFrame.
|
||||
|
||||
This method returns the excess kurtosis rather than the raw kurtosis.
|
||||
Excess kurtosis is calculated by subtracting 3 from the raw kurtosis,
|
||||
which offsets it relative to the kurtosis of a normal distribution.
|
||||
|
||||
category: Summary statistics
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"axis": (("index", "columns"),),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
|
||||
"""
|
||||
Computes the unbiased kurtosis of the DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the series.
|
||||
"""
|
||||
if axis=="index":
|
||||
series = dataframe.kurtosis(axis=0)
|
||||
elif axis=="columns":
|
||||
series = dataframe.kurtosis(axis=1)
|
||||
else:
|
||||
raise ValueError("Invalid axis. Only index or columns are supported.")
|
||||
return (series,)
|
||||
@@ -45,7 +45,7 @@ class PandasRename:
|
||||
new_label (str): The new label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the renamed DataFrame.
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
if axis=="index":
|
||||
df_out = dataframe.rename(index={current_label:new_label})
|
||||
|
||||
@@ -37,7 +37,7 @@ class PandasSelectRows:
|
||||
condition (str): A string representing the condition to filter rows.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the filtered DataFrame.
|
||||
tuple: A tuple containing the filtered DataFrame.
|
||||
"""
|
||||
# Apply condition
|
||||
df2 = dataframe.query(condition)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasSkew:
|
||||
"""
|
||||
Computes the unbiased skewness of the DataFrame.
|
||||
|
||||
category: Summary statistics
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"dataframe": ("DATAFRAME", {}),
|
||||
"axis": (("index", "columns"),),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PDSERIES",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, dataframe: pd.DataFrame, axis: str) -> tuple:
|
||||
"""
|
||||
Computes the unbiased skewness of the DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
axis (str): Specify the direction to compute: Index (row label) or column label.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the series.
|
||||
"""
|
||||
if axis=="index":
|
||||
series = dataframe.skew(axis=0)
|
||||
elif axis=="columns":
|
||||
series = dataframe.skew(axis=1)
|
||||
else:
|
||||
raise ValueError("Invalid axis. Only index or columns are supported.")
|
||||
return (series,)
|
||||
@@ -39,7 +39,7 @@ class PandasSort:
|
||||
ascending (bool): Whether to sort in ascending order.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the sorted DataFrame.
|
||||
tuple: A tuple containing the sorted DataFrame.
|
||||
"""
|
||||
df2 = dataframe.sort_values(by=column_name, ascending=ascending)
|
||||
return (df2,)
|
||||
|
||||
@@ -34,6 +34,6 @@ class PandasTranspose:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a JSON string of the transposed DataFrame.
|
||||
tuple: A tuple containing the transposed DataFrame.
|
||||
"""
|
||||
return (dataframe.transpose(),)
|
||||
|
||||
Reference in New Issue
Block a user