Skip to content

Commit

Permalink
fix: remove duplicated node_id column if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Aug 12, 2024
1 parent 6c88140 commit 5a9a00a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/kiara_plugin/tropy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,18 @@ def create_from_networkx_graph(
k: v if v else {"_x_placeholder_x_": "__dummy__"}
for k, v in graph.nodes(data=True)
}

nodes_data = pd.DataFrame.from_dict(node_dict, orient="index")
nodes_data = nodes_data.reset_index()

if "_x_placeholder_x_" in nodes_data.columns:
nodes_data = nodes_data.drop("_x_placeholder_x_", axis=1)
nodes_data = nodes_data.rename(columns={"index": node_id_column_name})

if node_id_column_name in nodes_data.columns:
# remove index column if it exists
nodes_data = nodes_data.drop("index", axis=1)
else:
nodes_data = nodes_data.rename(columns={"index": node_id_column_name})

nodes_table = KiaraTable.create_table(nodes_data)

Expand Down

0 comments on commit 5a9a00a

Please sign in to comment.