👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am trying to join two pandas data frames using two columns:
new_df = pd.merge(A_df, B_df, how="left", left_on="[A_c1,c2]", right_on = "[B_c1,c2]")
but got the following error:
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4164)()
pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4028)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13166)()
pandas/src/hashtable_class_helper.pxi in pandas.hashtable.PyObjectHashTable.get_item (pandas/hashtable.c:13120)()
KeyError: "[B_1, c2]"
Any idea what should be the right way to do this? Thanks!
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from pandas: merge (join) two data frames on multiple columns, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano pandas: merge (join) two data frames on multiple columns
- Deutsch pandas: merge (join) two data frames on multiple columns
- Français pandas: merge (join) two data frames on multiple columns
- Español pandas: merge (join) two data frames on multiple columns
- Türk pandas: merge (join) two data frames on multiple columns
- Русский pandas: merge (join) two data frames on multiple columns
- Português pandas: merge (join) two data frames on multiple columns
- Polski pandas: merge (join) two data frames on multiple columns
- Nederlandse pandas: merge (join) two data frames on multiple columns
- 中文 pandas: merge (join) two data frames on multiple columns
- 한국어 pandas: merge (join) two data frames on multiple columns
- 日本語 pandas: merge (join) two data frames on multiple columns
- हिन्दी pandas: merge (join) two data frames on multiple columns
California | 2023-04-01
I was preparing for my coding interview, thanks for clarifying this - pandas: merge (join) two data frames on multiple columns in Python is not the simplest one. Will use it in my bachelor thesis
Berlin | 2023-04-01
re Python module is always a bit confusing 😭 pandas: merge (join) two data frames on multiple columns is not the only problem I encountered. Will get back tomorrow with feedback
Abu Dhabi | 2023-04-01
Simply put and clear. Thank you for sharing. pandas: merge (join) two data frames on multiple columns and other issues with code Python module was always my weak point 😁. I am just not quite sure it is the best method