Added Pandas Drop Duplicates node. Fixed Pandas Drop NA node to output a DataFrame instead of legacy JSON string.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
class PandasDropDuplicates:
|
||||
"""
|
||||
Drops duplicate rows from a Pandas DataFrame.
|
||||
|
||||
category: Data cleansing
|
||||
"""
|
||||
|
||||
@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:
|
||||
"""
|
||||
Drops duplicate rows from a Pandas DataFrame.
|
||||
|
||||
Args:
|
||||
dataframe (DataFrame): The DataFrame.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
return (dataframe.drop_duplicates(),)
|
||||
@@ -37,4 +37,4 @@ class PandasDropNA:
|
||||
Returns:
|
||||
tuple: A tuple containing the DataFrame.
|
||||
"""
|
||||
return (dataframe.dropna().to_json(),)
|
||||
return (dataframe.dropna(),)
|
||||
|
||||
Reference in New Issue
Block a user