Currently I have two dataframes. One with a few filled columns including Names
and a bunch of empty columns. The other dataframe has all the empty columns of the first filled. I'm trying to populate the empty columns of the first dataframe with the data in the second dataframe only if the dataframes share a cell value.
Example:
DB:
Amount Foil? Name Set ....
3 nan purify the grave innistrad
2 nan slayer of the wicked innistrad
1 nan doomed traveler innistrad
1 nan fiend hunter innistrad
DF:
eur name rarity tix usd set_name ....
0.21 Ballyrush Banneret common 0.02 0.17 Morningtide
0.34 Battletide Alchemist rare 0.01 0.88 Morningtide
0.05 Burrenton Bombardier common 0.01 0.03 Morningtide
0.03 Burrenton Shield-Bearer common 0.01 0.03 Morningtide
0.21 Cenn's Tactician uncommon 0.01 0.22 Morningtide
0.05 Changeling Sentinel common 0.01 0.08 Morningtide
0.04 Coordinated Barrage common 0.01 0.11 Morningtide
0.06 Daily Regimen uncommon 0.01 0.14 Morningtide
Now somewhere in DF
there should be a row with a matching name
and set
cell as in db
(db
has only the cards I have while df
has all the cards from all the sets I have). If so I want to be able to update the row in DB
with all the info in DF
. How should I go about doing this?
The wanted end behavior is
DB:
Amount Foil? Name Set usd ....
3 nan purify the grave innistrad .5
2 nan slayer of the wicked innistrad .7
1 nan doomed traveler innistrad .9
1 nan fiend hunter innistrad ...
What I've tried so far is
final_db = pd.concat([db, df.loc[df['name'].isin(db['Name'])]],ignore_index=True,sort=True)
where my thinking was that it would concatenate (while ignoring index
) DB
and a new database with the same length of DB
but made up of only rows that DF
has. This did not work. I'm unsure what to do from here.
As an added bonus I would really like to be able to do this with a semi fuzzy search in case they're misspellings in the name.