Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff rules for pandas-vet #561

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions examples/evaluation/langchain_trulens_full.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,7 @@
"\n",
"columns_to_drop = [col for col in df_records.columns if col not in columns_to_keep]\n",
"\n",
"df_records.drop(columns=columns_to_drop, inplace=True)\n",
"\n",
"df_records"
"df_records.drop(columns=columns_to_drop)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/evaluation/tru_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]
columns_to_drop = [col for col in df_records.columns if col not in columns_to_keep]

df_records.drop(columns=columns_to_drop, inplace=True)
df_records = df_records.drop(columns=columns_to_drop)

df_records["test"] = app_id.split("#")[0]
df_records["test_uuid"] = app_id.split("#")[1]
Expand Down
14 changes: 7 additions & 7 deletions examples/notebooks/langchain_multimodal_gemini.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@
" \"https://www.breville.com/content/dam/breville/us/catalog/products/images/sp0/sp0000166/tile.jpg\",\n",
" ],\n",
"}\n",
"df = pd.DataFrame(data=d)\n",
"df"
"products = pd.DataFrame(data=d)\n",
"products"
]
},
{
Expand Down Expand Up @@ -599,11 +599,11 @@
" collection_name=\"coffee_shop_ecommerce\", dimension=1408\n",
")\n",
"\n",
"for i in range(len(df)):\n",
" name = df.loc[i, \"name\"]\n",
" image = df.loc[i, \"image\"]\n",
" price = df.loc[i, \"price\"]\n",
" url = df.loc[i, \"url\"]\n",
"for i in range(len(products)):\n",
" name = products.loc[i, \"name\"]\n",
" image = products.loc[i, \"image\"]\n",
" price = products.loc[i, \"price\"]\n",
" url = products.loc[i, \"url\"]\n",
"\n",
" # Download this product's image and save it to the Colab filesystem.\n",
" # In a production system this binary data would be stored in Google Cloud Storage\n",
Expand Down
18 changes: 9 additions & 9 deletions libs/ragulate/ragstack_ragulate/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_all_data(self, recipes: List[str]) -> DataFrame:

for app in tru.get_apps():
dataset = app["app_id"]
df, metrics = tru.get_records_and_feedback([dataset])
df_records, metrics = tru.get_records_and_feedback([dataset])
all_metrics.extend(metrics)

columns_to_keep = [
Expand All @@ -33,24 +33,24 @@ def get_all_data(self, recipes: List[str]) -> DataFrame:
"total_cost",
]
columns_to_drop = [
col for col in df.columns if col not in columns_to_keep
col for col in df_records.columns if col not in columns_to_keep
]

df.drop(columns=columns_to_drop, inplace=True)
df["recipe"] = recipe
df["dataset"] = dataset
df_records = df_records.drop(columns=columns_to_drop)
df_records["recipe"] = recipe
df_records["dataset"] = dataset

# set negative values to None
for metric in metrics:
df.loc[df[metric] < 0, metric] = None
df_records.loc[df_records[metric] < 0, metric] = None

df_all = pd.concat([df_all, df], axis=0, ignore_index=True)
df_all = pd.concat([df_all, df_records], axis=0, ignore_index=True)

tru.delete_singleton()

df_all.reset_index(drop=True, inplace=True)
reset_df = df_all.reset_index(drop=True)

return df_all, list(set(all_metrics))
return reset_df, list(set(all_metrics))

def calculate_statistics(self, df: pd.DataFrame, metrics: list):
stats = {}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ select = [
"I",
"N",
"NPY",
"PD",
"PERF",
"RUF",
"SIM",
Expand Down
Loading