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
  HTML Decoder pandas dataframe column mbrown009 3 1,030 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,119 Jan-06-2023, 10:53 PM
Last Post: haihal
  Pandas Dataframe Filtering based on rows mvdlm 0 1,432 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 2,312 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,261 Jan-30-2022, 10:21 AM
Last Post: anto5
  PANDAS: DataFrame | Replace and others questions moduki1 2 1,797 Jan-10-2022, 07:19 PM
Last Post: moduki1
  PANDAS: DataFrame | Saving the wrong value moduki1 0 1,551 Jan-10-2022, 04:42 PM
Last Post: moduki1
  update values in one dataframe based on another dataframe - Pandas iliasb 2 9,265 Aug-14-2021, 12:38 PM
Last Post: jefsummers
  empty row in pandas dataframe rwahdan 3 2,448 Jun-22-2021, 07:57 PM
Last Post: snippsat
  How to set the font size for a pandas table? AlekseyPython 0 2,323 Feb-06-2021, 03:37 AM
Last Post: AlekseyPython

Forum Jump:

User Panel Messages

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