Python Forum
pandas Dataframe as "confidence table" for matchmaking?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas Dataframe as "confidence table" for matchmaking?
#1
Hi,

I wonder if I am on the right track and would like to get your input on my problem:

Goal:
Find a link between two rows in two tables based on a number of criteria. 

Approach:
I want to work with a "match score or "confidence level" to determine, based on all my match criteria, which row in table 2 is most likely related to table 1.
In order to keep track of the "match score " I figured a dataframe with the unique row identifiers of table 1 and 2 as index and column would enable me to perform all my match criteria and constantly update the corresponding "match score" in the dataframe .

Question:

The problem I am having is that my way of updating the dataframe is not being saved.

I made a simple example to test my dataframe question. In the example below I point to the intersection of the "match score" that needs to be updated, and update the score, but for the next match the score is again updated from the original value of 0, therefore giving me an end result of 10 instead of my desired 50.

import pandas as pd
import numpy as np

table_1 = ('s1','s2','s3','s4','s5')
table_2 = ('i1','i2','i3','i4','i5')


df = pd.DataFrame(index = table_1, columns = table_2)
df = df.fillna(0)

for s in table_1:
df2= df.loc['s3','i4'] =+ 10




print(df)
Output:
    i1  i2  i3  i4  i5 s1   0   0   0   0   0 s2   0   0   0   0   0 s3   0   0   0  10   0 s4   0   0   0   0   0 s5   0   0   0   0   0
Do you know how I can save my change to the dataframe?

Also if you have any other conceptual suggestions on how I approach my goal I am happy to hear.
Reply
#2
I did find an answer to the question posted. 



for s in table_1:
    df1= df.loc['s3','i4']
    df2 = df.set_value('s3', 'i4', df1 +10, takeable=False)
If somebody has any suggestion regarding the approach I am taking I am happy to hear
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Formatting cells of a pandas dataframe into an OpenDocument ods spreadsheet Calab 1 523 Mar-01-2025, 04:51 AM
Last Post: Calab
  Find duplicates in a pandas dataframe list column on other rows Calab 2 1,965 Sep-18-2024, 07:38 PM
Last Post: Calab
  Find strings by index from a list of indexes in a different Pandas dataframe column Calab 3 1,562 Aug-26-2024, 04:52 PM
Last Post: Calab
  Add NER output to pandas dataframe dg3000 0 1,118 Apr-22-2024, 08:14 PM
Last Post: dg3000
  HTML Decoder pandas dataframe column mbrown009 3 2,586 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 1,964 Jan-06-2023, 10:53 PM
Last Post: haihal
  Pandas Dataframe Filtering based on rows mvdlm 0 2,042 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 3,360 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,876 Jan-30-2022, 10:21 AM
Last Post: anto5
  PANDAS: DataFrame | Replace and others questions moduki1 2 2,581 Jan-10-2022, 07:19 PM
Last Post: moduki1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020