Sep-24-2021, 03:41 AM
(This post was last modified: Sep-24-2021, 06:05 AM by Yoriz.
Edit Reason: Added code tags
)
I have a set of data A
Utlimately, I want the final output to be like
Output:19 101 Tampines
20 36 Mt Vernon
21 408 Fajar Rd
22 158 Tampines
23 8 Kim Tian
Then, I have another set of data BOutput: Driver Address
0 TOM Lorong Puntong
1 NEO Old Upp Thomson
2 TIM Bishan
3 NEO Peminmpin
4 NEO Sin Ming
5 NEO Pemimpin
6 NEO Jalan Ikan Merah
7 NEO Mt Vernon
8 NEO Fajar
9 NEO Kim Tian
10 TEO Tampines
I would like the a kind of "Excel Vlookup" kindda of function i.e. I want data Set A to have the Driver.Utlimately, I want the final output to be like
Output:101 Tampines Teo
36 Mt Vernon Neo
408 Fajar Rd Neo
158 Tampines Teo
8 Kim Tian Neo
Do I do it below way? If yes, I faced an errordf2=pd.merge(union1, df1, how='inner', on=None, left_on=None, right_on='Address',left_index=False, right_index=False, sort=True)
Error:ValueError: Cannot merge a Series without a name
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-286-519b6cc1e80a> in <module>
----> 1 df2=pd.merge(union1, df1, how='inner', on=None, left_on=None, right_on='Address',left_index=False, right_index=False, sort=True)
~\anaconda3\lib\site-packages\pandas\core\reshape\merge.py in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
71 validate=None,
72 ) -> "DataFrame":
---> 73 op = _MergeOperation(
74 left,
75 right,
~\anaconda3\lib\site-packages\pandas\core\reshape\merge.py in __init__(self, left, right, how, on, left_on, right_on, axis, left_index, right_index, sort, suffixes, copy, indicator, validate)
569 validate=None,
570 ):
--> 571 _left = _validate_operand(left)
572 _right = _validate_operand(right)
573 self.left = self.orig_left = _left
~\anaconda3\lib\site-packages\pandas\core\reshape\merge.py in _validate_operand(obj)
2000 elif isinstance(obj, ABCSeries):
2001 if obj.name is None:
-> 2002 raise ValueError("Cannot merge a Series without a name")
2003 else:
2004 return obj.to_frame()
ValueError: Cannot merge a Series without a name