Skip to content

RAGStringQueryEngine vs.graph_rag_retriever in query pandas dataframes #14533

Answered by dosubot bot
mraguth asked this question in Q&A
Discussion options

You must be logged in to vote

To convert your pandas dataframe df with columns ID, Pathway, and Process into the required format for nodes to be used with KnowledgeGraphIndex, you can use the following code:

import pandas as pd

# Assuming df is your dataframe
# df = pd.DataFrame({
#     'ID': [...],
#     'Pathway': [...],
#     'Process': [...]
# })

# Create the nodes dictionary
nodes = {}
for index, row in df.iterrows():
    nodes[row['ID']] = {
        "doc_id": row['ID'],
        "embedding": None,
        "extra_info": None,
        "index": index,
        "child_indices": [],
        "ref_doc_id": None,
        "node_info": {
            "Pathway": row['Pathway'],
            "Process": row['Process']
       …

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
4 replies
@mraguth
Comment options

@dosubot
Comment options

@mraguth
Comment options

@dosubot
Comment options

Comment options

You must be logged in to vote
3 replies
@dosubot
Comment options

@mraguth
Comment options

@dosubot
Comment options

Comment options

You must be logged in to vote
4 replies
@dosubot
Comment options

@mraguth
Comment options

@mraguth
Comment options

@dosubot
Comment options

Answer selected by mraguth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant