Unable To Use Map Function With Multi-index To Inject Series Into Pandas Dataframe
The Data: data = {'uid':{'0':'abc123','1':'abc123','2':'abc','3':'abc','4':'efgh'},'comp_id':{'0':1395,'1':2467,'2':4567,'3':1596,'4':111222},'retailer':{'0':'Shmo','1':'Joe','2':'
Solution 1:
Try this:
In [174]: vals = df[['uid','comp_id']].set_index(['comp_id','uid']).join(s).values
In [175]: vals
Out[175]:
array([['True'],
['True'],
['True'],
['True'],
['True']], dtype=object)
In [176]: df.insert(2, 'availability', vals)
In [177]: df
Out[177]:
comp_id price availability retailer uid
0 1395 7.49 True Shmo abc123
1 2467 5.17 True Joe abc123
2 4567 89.99 True Jon abc
3 1596 13.99 True Sam abc
4 111222 4.98 True Tim efgh
Post a Comment for "Unable To Use Map Function With Multi-index To Inject Series Into Pandas Dataframe"