text_html_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train_df = pd.read_csv('/kaggle/input/tabular-playground-series-aug-2022/train.csv')
test_df = pd.read_csv('/kaggle/input/tabular-playground-series-aug-2022/test.csv')
sample_submission_df = pd.read_csv('/kaggle/input/tabular-playground-series-aug-2022/sample_submission.csv')

train_df.dtypes

test_df.dtypes

train_df.columns

test_df.columns

train_null_count = train_df.isna().sum().to_dict()
df_train = pd.DataFrame([train_null_count.keys(), train_null_count.values()]).T
df_train.rename(columns={0: 'FeatureName', 1: 'NullCountTrain'}, inplace=True)
df_train

test_null_count = test_df.isna().sum().to_dict()
df_test = pd.DataFrame([test_null_count.keys(), test_null_count.values()]).T
df_test.rename(columns={0: 'FeatureName', 1: 'NullCountTest'}, inplace=True)
df_test

merged_dataset_null_counts = df_train.merge(df_test, how='outer').dropna()
merged_dataset_null_counts

df_train_temp = df_train.copy().rename(columns={'NullCountTrain': 'NullCount'})
df_train_temp['dataset'] = 'train'
df_train_temp = df_train_temp[df_train_temp['FeatureName'] != 'failure']
df_test_temp = df_test.copy().rename(columns={'NullCountTest': 'NullCount'})
df_test_temp['dataset'] = 'test'
df_temp = pd.concat([df_train_temp, df_test_temp], axis=0)

object_columns = list(train_df.select_dtypes(include=['object']).columns)
numeric_columns = [item for item in train_df.columns if item not in object_columns + ['failure']]

columns_with_not_null_values = [col for col in train_df.notnull().columns if col != 'failure']
df_tmp = pd.DataFrame(train_df.isna().any(), columns=['isnan'])
NaN_columns = list(df_tmp[df_tmp['isnan'] == True].T.columns)
del df_tmp
label_column = 'failure'
print(f'Colums -> {columns_with_not_null_values}\nLabel Column -> {label_column}\n NaN Columns -> {NaN_columns}')