Skip to content

Commit b18833a

Browse files
committed
set numeric_only=True for pandas 2.0 breaking changes
1 parent f8c6d5b commit b18833a

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

graphein/protein/edges/distance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def get_ring_centroids(ring_atom_df: pd.DataFrame) -> pd.DataFrame:
12101210
"""
12111211
return (
12121212
ring_atom_df.groupby("node_id")
1213-
.mean()[["x_coord", "y_coord", "z_coord"]]
1213+
.mean(numeric_only=True)[["x_coord", "y_coord", "z_coord"]]
12141214
.reset_index()
12151215
)
12161216

graphein/protein/features/nodes/geometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def add_sidechain_vector(
4747
if "rgroup_df" not in g.graph.keys():
4848
g.graph["rgroup_df"] = compute_rgroup_dataframe(g.graph["raw_pdb_df"])
4949

50-
sc_centroid = g.graph["rgroup_df"].groupby("node_id").mean()
50+
sc_centroid = g.graph["rgroup_df"].groupby("node_id").mean(numeric_only=True)
5151

5252
# Iterate over nodes and compute vector
5353
for n, d in g.nodes(data=True):

graphein/protein/graphs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ def number_groups_of_runs(list_of_values: List[Any]) -> List[str]:
11381138
"""
11391139
df = pd.DataFrame({"val": list_of_values})
11401140
df["idx"] = df["val"].shift() != df["val"]
1141-
df["sum"] = df.groupby("val")["idx"].cumsum()
1141+
df["sum"] = df.groupby("val")["idx"].cumsum(numeric_only=True)
11421142
return list(df["val"].astype(str) + df["sum"].astype(str))
11431143

11441144

graphein/protein/tensor/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def protein_to_pyg(
267267

268268
if store_bfactor:
269269
# group by residue_id and average b_factor per residue
270-
residue_bfactors = df.groupby("residue_id")["b_factor"].mean()
270+
residue_bfactors = df.groupby("residue_id")["b_factor"].mean(numeric_only=True)
271271
out.bfactor = torch.from_numpy(residue_bfactors.values)
272272

273273
return out

tests/protein/nodes/features/test_geometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_add_sidechain_vector():
138138
sc_true = np.array(
139139
g.graph["rgroup_df"]
140140
.groupby("node_id")
141-
.mean()
141+
.mean(numeric_only=True)
142142
.loc[n][["x_coord", "y_coord", "z_coord"]]
143143
)
144144
np.testing.assert_almost_equal(

0 commit comments

Comments
 (0)