<jupyter_start><jupyter_text>merge 操作<jupyter_code>import pandas as pd
left = pd.DataFrame({'key':['K0','K1','K2','K3'],
                    'A':['A0','A1','A2','A3'],
                    'B':['B0','B1','B2','B3']})

right = pd.DataFrame({'key':['K0','K1','K2','K3'],
                    'C':['C0','C1','C2','C3'],
                    'D':['D0','D1','D2','D3']})
left
right
pd.merge(left,right)
pd.merge(left,right, on='key')
left = pd.DataFrame({'key1':['K0','K1','K2','K3'],
                     'key2':['K0','K1','K2','K3'],
                    'A':['A0','A1','A2','A3'],
                    'B':['B0','B1','B2','B3']})

right = pd.DataFrame({'key1':['K0','K1','K2','K3'],
                    'key2':['K0','K1','K2','K4'],
                    'C':['C0','C1','C2','C3'],
                    'D':['D0','D1','D2','D3']})
pd.merge(left,right, on='key1')
pd.merge(left,right, on=['key1','key2'])
pd.merge(left,right, on=['key1','key2'],how='outer', indicator=True)
pd.merge(left,right, on=['key1','key2'],how='left')
pd.merge(left,right, on=['key1','key2'],how='right')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.3226982680036463, 'fraction_numerical': 0.06289881494986327, 'mean_word_length': 3.272373540856031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '600520', 'license': 'MIT', 'n_tokens_mistral': 469, 'n_tokens_neox': 458, 'n_words': 39, 'path': 'pandas_demo/pandas_merge.ipynb', 'repo_name': 'ftconan/python3', 'size': '1097'}