Hi have a dataframe with 10000+ rows which looks like this -
df = pd.DataFrame([[\'110\', \'Demand\', 2344, 30953],
[\'111\', \'Supply\', 353
Use DataFrame.update, but first create MultiIndex
by Material
and Title
columns in both DataFrame
s:
df = df.set_index(['Material','Title'])
extra = extra.set_index(['Material','Title'])
df.update(extra)
df = df.astype(int).reset_index()
print (df)
Material Title 201950 201951
0 110 Demand 2344 30953
1 111 Supply 10 321312
2 112 Supply 20 2324
3 113 Demand 24345 4542
4 114 Supply 30 435623