Skip to content

Commit a4af55c

Browse files
committed
Use list comprehensions
1 parent 0913231 commit a4af55c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

graphrag/index/flows/create_base_entity_graph.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def _prep_communities(communities) -> pd.DataFrame:
168168

169169

170170
def _compute_degree(graph: nx.Graph) -> pd.DataFrame:
171-
degrees = []
172-
for node, degree in graph.degree: # type: ignore
173-
degrees.append({"name": node, "degree": int(degree)})
174-
return pd.DataFrame(degrees)
171+
return pd.DataFrame([
172+
{"name": node, "degree": int(degree)} for node, degree in graph.degree
173+
]) # type: ignore

graphrag/index/flows/create_final_communities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def create_final_communities(
6060

6161
# join it all up and add some new fields
6262
communities = all_grouped.merge(entity_ids, on="community", how="inner")
63-
communities["id"] = communities["community"].apply(lambda _x: str(uuid4()))
63+
communities["id"] = [str(uuid4()) for _ in range(len(communities))]
6464
communities["human_readable_id"] = communities["community"]
6565
communities["title"] = "Community " + communities["community"].astype(str)
6666

0 commit comments

Comments
 (0)