<jupyter_start><jupyter_text>merge dataframe and split again.Useful for merging test and train data to create panel.Then apply transformations on panel in one go.Finally split the panel back into train and test dataframes.<jupyter_code>import pandas as pd
import numpy as np
ts1 = [1,2,3,4]
ts2 = [6,7,8,9]
d = {'col_1': ts1, 'col_2': ts2}
d
df_1 = pd.DataFrame(data=d)
df_1
df_2 = pd.DataFrame(np.random.randn(3, 2), columns=['col_1', 'col_2'])
df_2
df_all = pd.concat((df_1, df_2), axis=0, ignore_index=True)
df_all
print(df_1.shape)
print(df_2.shape)
print(df_all.shape)
df_train = df_all[:df_1.shape[0]]
df_test = df_all[df_1.shape[0]:]
print(df_train.shape)
print(df_test.shape)
print(df_all.shape)<jupyter_output>(4, 2)
(3, 2)
(7, 2)
{'fraction_non_alphanumeric': 0.14749661705006767, 'fraction_numerical': 0.05006765899864682, 'mean_word_length': 6.254901960784314, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '18303', 'license': 'MIT', 'n_tokens_mistral': 326, 'n_tokens_neox': 316, 'n_words': 77, 'path': '3_c_merge_two_dataframes_and_split_again.ipynb', 'repo_name': 'mj111312/pandas_basics', 'size': '739'}