This repository contains a unit test script (test_code.py
) designed to validate code in a Data Science project. The project involves data manipulation and analysis using Python, Pandas, and other relevant libraries.
Clone this repository into your Google Colab environment:
!git clone https://github.com/Brritany/TestCode.git
After cloning, import the TestCode
class from test_code.py
and run the unit tests as follows:
from TestCode.test_code import TestCode
import unittest
suite = unittest.TestLoader().loadTestsFromTestCase(TestCode)
unittest.TextTestRunner().run(suite)
The unit tests include the following:
test_discharge_summary
: Checks if all 'Discharge summary' records are filtered from NOTEEVENTS.test_merged_data
: Confirms whether the columns 'SUBJECT_ID' and 'HADM_ID' exist in the DataFrame, indicating successful merging of NOTEEVENTS, PATIENTS, and ADMISSIONS tables.test_final_admission
: Ensures that each 'SUBJECT_ID' appears only once in the finalfinal_admission.csv
.test_exclude_newborn
: Checks if all newborns have been excluded.test_exclude_dih
: Checks if all in-hospital deaths have been excluded.test_final_count
: Ensures that the finalfinal_admission.csv
has 32,174 records (as per your setup).
- Python 3.x
- Pandas
Yong Zhen Huang