Skip to content

Commit 13d495f

Browse files
authored
Add ruff rules for pandas-vet (#561)
1 parent e6ed532 commit 13d495f

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

examples/evaluation/langchain_trulens_full.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,7 @@
468468
"\n",
469469
"columns_to_drop = [col for col in df_records.columns if col not in columns_to_keep]\n",
470470
"\n",
471-
"df_records.drop(columns=columns_to_drop, inplace=True)\n",
472-
"\n",
473-
"df_records"
471+
"df_records.drop(columns=columns_to_drop)"
474472
]
475473
},
476474
{

examples/evaluation/tru_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
]
2323
columns_to_drop = [col for col in df_records.columns if col not in columns_to_keep]
2424

25-
df_records.drop(columns=columns_to_drop, inplace=True)
25+
df_records = df_records.drop(columns=columns_to_drop)
2626

2727
df_records["test"] = app_id.split("#")[0]
2828
df_records["test_uuid"] = app_id.split("#")[1]

examples/notebooks/langchain_multimodal_gemini.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@
551551
" \"https://www.breville.com/content/dam/breville/us/catalog/products/images/sp0/sp0000166/tile.jpg\",\n",
552552
" ],\n",
553553
"}\n",
554-
"df = pd.DataFrame(data=d)\n",
555-
"df"
554+
"products = pd.DataFrame(data=d)\n",
555+
"products"
556556
]
557557
},
558558
{
@@ -599,11 +599,11 @@
599599
" collection_name=\"coffee_shop_ecommerce\", dimension=1408\n",
600600
")\n",
601601
"\n",
602-
"for i in range(len(df)):\n",
603-
" name = df.loc[i, \"name\"]\n",
604-
" image = df.loc[i, \"image\"]\n",
605-
" price = df.loc[i, \"price\"]\n",
606-
" url = df.loc[i, \"url\"]\n",
602+
"for i in range(len(products)):\n",
603+
" name = products.loc[i, \"name\"]\n",
604+
" image = products.loc[i, \"image\"]\n",
605+
" price = products.loc[i, \"price\"]\n",
606+
" url = products.loc[i, \"url\"]\n",
607607
"\n",
608608
" # Download this product's image and save it to the Colab filesystem.\n",
609609
" # In a production system this binary data would be stored in Google Cloud Storage\n",

libs/ragulate/ragstack_ragulate/analysis.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_all_data(self, recipes: List[str]) -> DataFrame:
2222

2323
for app in tru.get_apps():
2424
dataset = app["app_id"]
25-
df, metrics = tru.get_records_and_feedback([dataset])
25+
df_records, metrics = tru.get_records_and_feedback([dataset])
2626
all_metrics.extend(metrics)
2727

2828
columns_to_keep = [
@@ -33,24 +33,24 @@ def get_all_data(self, recipes: List[str]) -> DataFrame:
3333
"total_cost",
3434
]
3535
columns_to_drop = [
36-
col for col in df.columns if col not in columns_to_keep
36+
col for col in df_records.columns if col not in columns_to_keep
3737
]
3838

39-
df.drop(columns=columns_to_drop, inplace=True)
40-
df["recipe"] = recipe
41-
df["dataset"] = dataset
39+
df_records = df_records.drop(columns=columns_to_drop)
40+
df_records["recipe"] = recipe
41+
df_records["dataset"] = dataset
4242

4343
# set negative values to None
4444
for metric in metrics:
45-
df.loc[df[metric] < 0, metric] = None
45+
df_records.loc[df_records[metric] < 0, metric] = None
4646

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

4949
tru.delete_singleton()
5050

51-
df_all.reset_index(drop=True, inplace=True)
51+
reset_df = df_all.reset_index(drop=True)
5252

53-
return df_all, list(set(all_metrics))
53+
return reset_df, list(set(all_metrics))
5454

5555
def calculate_statistics(self, df: pd.DataFrame, metrics: list):
5656
stats = {}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ select = [
8585
"LOG",
8686
"N",
8787
"NPY",
88+
"PD",
8889
"PERF",
8990
"PIE",
9091
"PGH",

0 commit comments

Comments
 (0)