text_html_output_1.png
import pandas as pd

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

import warnings

import warnings
warnings.filterwarnings('ignore', category=UserWarning)
warnings.filterwarnings('ignore', category=pd.errors.PerformanceWarning)
warnings.filterwarnings('ignore', category=FutureWarning)

train_df = pd.read_csv('/kaggle/input/playground-series-s3e13/train.csv')
test_df = pd.read_csv('/kaggle/input/playground-series-s3e13/test.csv')
submission_df = pd.read_csv('/kaggle/input/playground-series-s3e13/sample_submission.csv')
train_df = train_df.set_index('id')
test_df = test_df.set_index('id')

def convert_to_string(row):
    row_dict = row.to_dict()
    base = 'a person with the symptoms '
    for symptom, value in row_dict.items():
        if symptom == 'prognosis':
            continue
        elif value == 1:
            base += symptom.replace('_', ' ') + ', '
    base = base.rstrip(', ')
    return base

train_df['text_symptom'] = train_df.apply(convert_to_string, axis=1)
test_df['text_symptom'] = test_df.apply(convert_to_string, axis=1)

train_df['prognosis'].head(5).values