BUG: merge_ordered should raise when elements in by not exist in df (original) (raw)
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
l = pd.DataFrame([['g', 'h', 1], ['g', 'h', 3]], columns=list('GHT')) l G H T 0 g h 1 1 g h 3 r = pd.DataFrame([[2, 1]], columns=list('TE')) r T E 0 2 1
Result
pd.merge_ordered(l, r, on='T', left_by=['G', 'h'])
| G | H | T | E | h | |
|---|---|---|---|---|---|
| 0 | G | h | 1 | nan | G |
| 1 | G | nan | 2 | 1 | G |
| 2 | h | nan | 2 | 1 | h |
| 3 | h | h | 3 | nan | h |
expected
pd.merge_ordered(l, r, on='T', left_by=['G', 'h']) KeyError: "['h'] not found in left columns"