text_html_output_1.png
import pandas as pd

df = pd.read_csv('/kaggle/input/playground-series-s3e9/train.csv')
df.drop(columns='id', inplace=True)

df_add = pd.read_csv('/kaggle/input/predict-concrete-strength/ConcreteStrengthData.csv')
df_add.rename(columns={'CementComponent ': 'CementComponent'}, inplace=True)
df = pd.concat([df, df_add])

df_test = pd.read_csv('/kaggle/input/playground-series-s3e9/test.csv')
df_test.drop(columns='id', inplace=True)

y = df.pop('Strength')
df['tot_comp'] = df.iloc[:, :7].sum(axis=1)
df['ageinmonth'] = df.AgeInDays // 30 / 12
df['AgeInDays'] = df.AgeInDays / 365
df_test['tot_comp'] = df_test.iloc[:, :7].sum(axis=1)
df_test['ageinmonth'] = df_test.AgeInDays // 30 / 12
df_test['AgeInDays'] = df_test.AgeInDays / 365

df_transform = df.iloc[:, :7].transform(lambda x: x / df.tot_comp)
df_transform = pd.concat([df_transform, df.AgeInDays, df.ageinmonth], axis=1)
df_test_transform = df_test.iloc[:, :7].transform(lambda x: x / df_test.tot_comp)
df_test_transform = pd.concat([df_test_transform, df_test.AgeInDays, df_test.ageinmonth], axis=1)

df_transform.head()