Spaces:
Sleeping
Sleeping
Commit
·
62b003e
1
Parent(s):
be9fa47
updated the smolagents
Browse files- Oracle/DataSmolAgent.py +3 -25
Oracle/DataSmolAgent.py
CHANGED
@@ -5,28 +5,14 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
5 |
|
6 |
@tool
|
7 |
def clean_data(df: pd.DataFrame) -> pd.DataFrame:
|
8 |
-
"""Clean the DataFrame by stripping
|
9 |
-
|
10 |
-
Args:
|
11 |
-
df (pd.DataFrame): The input DataFrame containing the raw data.
|
12 |
-
|
13 |
-
Returns:
|
14 |
-
pd.DataFrame: A cleaned DataFrame with stripped column names and without completely empty rows.
|
15 |
-
"""
|
16 |
df.columns = df.columns.str.strip()
|
17 |
df = df.dropna(how="all")
|
18 |
return df
|
19 |
|
20 |
@tool
|
21 |
def extract_features(df: pd.DataFrame) -> pd.DataFrame:
|
22 |
-
"""Dynamically extract features from the DataFrame.
|
23 |
-
|
24 |
-
Args:
|
25 |
-
df (pd.DataFrame): The input DataFrame containing the raw data.
|
26 |
-
|
27 |
-
Returns:
|
28 |
-
pd.DataFrame: The DataFrame updated with new dynamically engineered features.
|
29 |
-
"""
|
30 |
# Numeric columns: log transformation
|
31 |
numeric_cols = df.select_dtypes(include=[np.number]).columns.to_list()
|
32 |
for col in numeric_cols:
|
@@ -59,15 +45,7 @@ def extract_features(df: pd.DataFrame) -> pd.DataFrame:
|
|
59 |
|
60 |
@tool
|
61 |
def save_to_csv(df: pd.DataFrame, filename: str = "output.csv") -> str:
|
62 |
-
"""Save the DataFrame to a CSV file.
|
63 |
-
|
64 |
-
Args:
|
65 |
-
df (pd.DataFrame): The DataFrame to save.
|
66 |
-
filename (str): The name of the output CSV file (default "output.csv").
|
67 |
-
|
68 |
-
Returns:
|
69 |
-
str: The file path of the saved CSV.
|
70 |
-
"""
|
71 |
df.to_csv(filename, index=False)
|
72 |
return filename
|
73 |
|
|
|
5 |
|
6 |
@tool
|
7 |
def clean_data(df: pd.DataFrame) -> pd.DataFrame:
|
8 |
+
"""Clean the input DataFrame (df) by stripping column whitespace and dropping empty rows."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
df.columns = df.columns.str.strip()
|
10 |
df = df.dropna(how="all")
|
11 |
return df
|
12 |
|
13 |
@tool
|
14 |
def extract_features(df: pd.DataFrame) -> pd.DataFrame:
|
15 |
+
"""Dynamically extract features from the input DataFrame (df)."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Numeric columns: log transformation
|
17 |
numeric_cols = df.select_dtypes(include=[np.number]).columns.to_list()
|
18 |
for col in numeric_cols:
|
|
|
45 |
|
46 |
@tool
|
47 |
def save_to_csv(df: pd.DataFrame, filename: str = "output.csv") -> str:
|
48 |
+
"""Save the input DataFrame (df) to a CSV file named 'filename'."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
df.to_csv(filename, index=False)
|
50 |
return filename
|
51 |
|