### Start Jupyter Notebook Server Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Command to launch the Jupyter Notebook server, allowing you to access and run the provided example notebooks from your web browser. ```bash jupyter notebook examples/ ``` -------------------------------- ### Demonstrate Various Demo Data Loading Options Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/00_clif_demo_data.ipynb Provides multiple examples of how to load demo data, including loading the complete dataset, loading specific tables, loading individual table objects, and getting raw pandas DataFrames. It also shows how to explore available datasets. ```python # Example 1: Load complete CLIF demo data from pyclif.data import load_demo_clif clif_demo = load_demo_clif() print(f"Demo patients: {len(clif_demo.patient.df)}") # Example 2: Load specific tables only clif_subset = load_demo_clif(tables=['patient', 'labs', 'vitals']) # Example 3: Load individual table objects from pyclif.data import load_demo_patient, load_demo_labs patient_data = load_demo_patient() labs_data = load_demo_labs() # Example 4: Get raw DataFrames patient_df = load_demo_patient(return_raw=True) labs_df = load_demo_labs(return_raw=True) # Example 5: Explore available datasets from pyclif.data import get_demo_summary, list_demo_datasets get_demo_summary() # Pretty print summary datasets_info = list_demo_datasets() # Example 6: Quick analysis from pyclif.data import load_demo_clif demo = load_demo_clif() demo.create_wide_dataset() # Test wide dataset creation ``` -------------------------------- ### Explore Demo Dataset Summary Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/00_clif_demo_data.ipynb Uses the `get_demo_summary()` function from `pyclif.data` to display a formatted summary of all available demo datasets within the pyCLIF library. ```python from pyclif.data import get_demo_summary # Print a nice summary of all demo datasets get_demo_summary() ``` -------------------------------- ### Import pyCLIF Library Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/00_clif_demo_data.ipynb Imports necessary libraries including pandas and the pyCLIF library for working with CLIF format healthcare data. ```python import sys import os import pandas as pd # Import the pyCLIF library from pyclif import CLIF from pyclif.data import load_demo_clif ``` -------------------------------- ### Load Complete CLIF Demo Object Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/00_clif_demo_data.ipynb Loads the entire CLIF demo dataset into a CLIF object, which contains all demo tables. It then demonstrates accessing individual tables and printing counts, such as the number of unique patients. ```python # Load complete CLIF object with all demo tables clif_demo = load_demo_clif() # Access individual tables print(f"\U0001f4ca Demo dataset contains:") print(f" Patients: {len(clif_demo.patient.df)} unique patients") ``` -------------------------------- ### Install pyCLIF Development Version Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/README.md Steps to clone the pyCLIF repository, set up a virtual environment, and install the package in development mode using pip. ```bash # Clone the repository git clone https://github.com/Common-Longitudinal-ICU-data-Format/pyCLIF.git cd pyCLIF # Create virtual environment python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install in development mode pip install -e . ``` -------------------------------- ### Load Individual CLIF Tables or Raw DataFrames Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/00_clif_demo_data.ipynb Demonstrates loading specific CLIF tables (e.g., patient, labs) as CLIF objects or retrieving them directly as pandas DataFrames using the `return_raw=True` option for direct analysis. ```python from pyclif.data import load_demo_patient, load_demo_labs # Load specific table objects patient_data = load_demo_patient() labs_data = load_demo_labs() # Or get raw DataFrames for direct analysis patient_df = load_demo_patient(return_raw=True) labs_df = load_demo_labs(return_raw=True) ``` -------------------------------- ### Create Wide Datasets with pyCLIF Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Explains how to initialize the `CLIF` object for auto-loading and create wide datasets from multiple tables. It covers creating a wide dataset with optional tables, category filters, sampling, and saving options, as well as targeting specific hospitalization IDs for focused analysis. ```python from pyclif import CLIF # Initialize CLIF with auto-loading capabilities clif = CLIF( data_dir="/Users/vaishvik/downloads/CLIF_MIMIC", filetype='parquet', timezone='US/Eastern' ) # Create wide dataset with automatic table loading wide_df = clif.create_wide_dataset( optional_tables=['vitals', 'labs', 'medication_admin_continuous'], category_filters={ 'vitals': ['map', 'heart_rate', 'spo2'], 'labs': ['hemoglobin', 'wbc', 'sodium'], 'medication_admin_continuous': ['norepinephrine', 'propofol'] }, sample=True, # Use 20 random hospitalizations save_to_data_location=True, output_format='parquet' ) # Or create for specific hospitalizations target_ids = ['12345', '67890'] wide_df_targeted = clif.create_wide_dataset( hospitalization_ids=target_ids, optional_tables=['patient_assessments'], category_filters={'patient_assessments': ['gcs_total', 'rass']}, output_filename='targeted_wide_dataset' ) ``` -------------------------------- ### Initialize CLIF with Timezone and Load Tables Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Demonstrates the core initialization of the CLIF class, specifying the data directory, file type, and site timezone. It then proceeds to load specified tables. ```python from pyclif import CLIF # Initialize with your settings clif = CLIF( data_dir="/Users/vaishvik/downloads/CLIF_MIMIC", filetype='parquet', timezone='US/Eastern' ) # Load tables clif.initialize(tables=['patient', 'vitals']) ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Command to activate the project's virtual environment. This ensures that all dependencies required by pyCLIF are available for execution. ```bash # From the project root directory source .venv/bin/activate ``` -------------------------------- ### Development Setup Git Workflow Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/README.md Steps for setting up the development environment and contributing changes using Git. This includes forking, branching, committing, and creating pull requests. ```git # Fork the repository # (Manual step via GitHub UI) ``` ```git # Create a feature branch git checkout -b feature/amazing-feature ``` ```git # Make your changes # (Edit files) ``` ```git # Run tests pytest ``` ```git # Commit your changes git commit -m "Add amazing feature" ``` ```git # Push to the branch git push origin feature/amazing-feature ``` ```git # Open a Pull Request # (Manual step via GitHub UI) ``` -------------------------------- ### Load and Process Individual pyCLIF Tables Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Shows how to load a specific table, like 'vitals', directly using `pyclif.tables.vitals.vitals.from_file()`. It also demonstrates using table-specific methods such as `filter_by_vital_category()` to subset data and `get_summary_stats()` for quick insights. ```python from pyclif.tables.vitals import vitals # Load vitals table directly vitals_table = vitals.from_file( table_path="/Users/vaishvik/downloads/CLIF_MIMIC", table_format_type="parquet" ) # Use table-specific methods hr_data = vitals_table.filter_by_vital_category('heart_rate') summary = vitals_table.get_summary_stats() ``` -------------------------------- ### Setup pyCLIF Environment Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/07_wide_dataset_creation.ipynb Imports necessary libraries (sys, os, pandas, pyclif) and sets up the Python path to include the pyclif source directory. It also configures warnings to be ignored for cleaner output. ```Python import sys import os sys.path.append('../src') import pandas as pd from pyclif import CLIF import warnings warnings.filterwarnings('ignore') print("=== pyCLIF Wide Dataset Example ===") ``` -------------------------------- ### Set Data Directory Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Specifies the path to the CLIF data directory. This variable needs to be updated to point to your local CLIF data location before running the examples. ```python DATA_DIR = "/Users/vaishvik/downloads/CLIF_MIMIC" # Or update to your path: # DATA_DIR = "/path/to/your/CLIF_MIMIC/data" ``` -------------------------------- ### Import Libraries and Setup Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/08_hourly_wide_dataset_creation.ipynb Imports necessary Python libraries such as pandas, numpy, and pyclif. It also configures warning filters for cleaner output during execution. ```python import sys import os sys.path.append('../src') import pandas as pd import numpy as np from pyclif import CLIF import warnings warnings.filterwarnings('ignore') print("=== pyCLIF Hourly Wide Dataset Example ===") ``` -------------------------------- ### Load pyCLIF Data with Filters and Timezone Conversion Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Illustrates memory-efficient data loading using `pyclif.utils.io.load_data`. It shows how to specify table name, path, format, select specific columns, apply category filters, limit sample size, and convert timezones, making it suitable for large datasets. ```python from pyclif.utils.io import load_data # Load with filters and timezone conversion vitals_data = load_data( table_name="vitals", table_path="/Users/vaishvik/downloads/CLIF_MIMIC", table_format_type="parquet", columns=['patient_id', 'vital_category', 'vital_value', 'recorded_dttm'], filters={'vital_category': ['heart_rate', 'sbp', 'dbp']}, sample_size=1000, site_tz="US/Eastern" ) ``` -------------------------------- ### Configure Site Timezone and File Format Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Illustrates how to configure the site's timezone and the expected file format for CLIF data. These settings are crucial for accurate data processing and interpretation. ```python # In CLIF class initialization clif = CLIF(data_dir=DATA_DIR, filetype='parquet', timezone='US/Eastern') # When loading data with a specific function data = load_data(..., site_tz='US/Eastern') # Specifying the table file format table_format_type = "parquet" ``` -------------------------------- ### Create Wide Datasets Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Illustrates the creation of wide-format datasets from longitudinal data, supporting automatic table loading, filtering by categories, sampling, and saving to specified formats. It also shows how to create datasets for specific hospitalizations. ```python from pyclif import CLIF # Initialize CLIF with auto-loading capabilities clif = CLIF( data_dir="/Users/vaishvik/downloads/CLIF_MIMIC", filetype='parquet', timezone='US/Eastern' ) # Create wide dataset with automatic table loading wide_df = clif.create_wide_dataset( optional_tables=['vitals', 'labs', 'medication_admin_continuous'], category_filters={ 'vitals': ['map', 'heart_rate', 'spo2'], 'labs': ['hemoglobin', 'wbc', 'sodium'], 'medication_admin_continuous': ['norepinephrine', 'propofol'] }, sample=True, # Use 20 random hospitalizations save_to_data_location=True, output_format='parquet' ) # Or create for specific hospitalizations target_ids = ['12345', '67890'] wide_df_targeted = clif.create_wide_dataset( hospitalization_ids=target_ids, optional_tables=['patient_assessments'], category_filters={'patient_assessments': ['gcs_total', 'rass']}, output_filename='targeted_wide_dataset' ) ``` -------------------------------- ### pyclif Development Setup Commands Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/README.md Essential shell commands for developers to set up their environment, create feature branches, run tests, commit changes, and push updates to the pyclif repository. These commands facilitate a standard Git-based development workflow. ```Shell git checkout -b feature/amazing-feature pytest git commit -m 'Add amazing feature' git push origin feature/amazing-feature ``` -------------------------------- ### Load and Filter Individual Tables Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Shows how to load specific data tables directly and utilize table-specific methods for filtering and summary statistics. This approach allows for granular control over data manipulation. ```python from pyclif.tables.vitals import vitals # Load vitals table directly vitals_table = vitals.from_file( table_path="/Users/vaishvik/downloads/CLIF_MIMIC", table_format_type="parquet" ) # Use table-specific methods hr_data = vitals_table.filter_by_vital_category('heart_rate') summary = vitals_table.get_summary_stats() ``` -------------------------------- ### Python Filtering Best Practices Summary Placeholder Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/06_data_filtering.ipynb This section serves as a placeholder for detailed explanations or code examples related to efficient data filtering techniques in Python. It indicates where best practices for filtering will be documented. ```python # Filtering Best Practices Summary ``` -------------------------------- ### Setup and Imports Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/06_data_filtering.ipynb Imports necessary Python libraries including pandas, numpy, matplotlib, seaborn, datetime, and pyCLIF components. It also sets up environment configurations and prints version information for Python and pandas. ```Python import sys import os import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from datetime import datetime, timedelta import warnings warnings.filterwarnings('ignore') # Import pyCLIF components from pyclif import CLIF from pyclif.tables.vitals import vitals from pyclif.tables.patient import patient from pyclif.tables.hospitalization import hospitalization from pyclif.utils.io import load_data print(f"Data filtering environment setup complete!") print(f"Python version: {sys.version}") print(f"Pandas version: {pd.__version__}") ``` -------------------------------- ### Load Data Efficiently with Filters Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Demonstrates memory-efficient loading of data tables using filters and timezone conversion. This method is useful for handling large datasets by selecting specific columns and rows. ```python from pyclif.utils.io import load_data # Load with filters and timezone conversion vitals_data = load_data( table_name="vitals", table_path="/Users/vaishvik/downloads/CLIF_MIMIC", table_format_type="parquet", columns=['patient_id', 'vital_category', 'vital_value', 'recorded_dttm'], filters={'vital_category': ['heart_rate', 'sbp', 'dbp']}, sample_size=1000, site_tz="US/Eastern" ) ``` -------------------------------- ### Memory Optimization and Filtering Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/docs/wide_dataset.md Provides examples for optimizing memory usage when creating wide datasets. It highlights the use of the `sample=True` parameter for testing or specifying `hospitalization_ids` for targeted analysis. ```python # Use sampling or filtering wide_df = clif.create_wide_dataset(sample=True) # or wide_df = clif.create_wide_dataset(hospitalization_ids=small_list) ``` -------------------------------- ### Integrating Wide Dataset into Workflow Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/docs/wide_dataset.md Shows how to integrate the wide dataset creation into an existing pyCLIF workflow. This example contrasts the traditional initialization with the enhanced wide dataset creation, including specifying optional tables and category filters. ```python # Traditional approach clif = CLIF(data_dir="/path/to/data") clif.initialize(['patient', 'vitals', 'labs']) # Enhanced with wide dataset wide_df = clif.create_wide_dataset( optional_tables=['vitals', 'labs'], category_filters={'vitals': ['map'], 'labs': ['hemoglobin']} ) # Continue with analysis analysis_results = analyze_wide_dataset(wide_df) ``` -------------------------------- ### Validate pyCLIF Data Objects Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/README.md Demonstrates how to check the validity of loaded patient and vitals data using the `isvalid()` method on `clif.patient` and `clif.vitals` objects. This helps ensure data integrity before further processing. ```python print(f"Patient data valid: {clif.patient.isvalid()}") print(f"Vitals data valid: {clif.vitals.isvalid()}") ``` -------------------------------- ### Vitals Table: Filter by Date Range Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/02_individual_tables.ipynb Filters the `vitals_table` to retrieve records within a specified date range. This example calculates a start date 30 days prior to the latest recorded timestamp and filters accordingly. ```python # Filter by date range from datetime import datetime, timedelta # Get recent data (last 30 days from the latest timestamp) if 'recorded_dttm' in vitals_table.df.columns: latest_date = pd.to_datetime(vitals_table.df['recorded_dttm']).max() start_date = latest_date - timedelta(days=30) recent_vitals = vitals_table.filter_by_date_range(start_date, latest_date) print(f"Recent vitals (last 30 days): {len(recent_vitals)} records") print(f"Date range: {start_date.date()} to {latest_date.date()}") ``` -------------------------------- ### Integrating pyCLIF Wide Dataset Creation into Workflows Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/docs/wide_dataset.md This example illustrates how to integrate the `create_wide_dataset` function into an existing `pyCLIF` workflow. It contrasts the traditional manual table initialization with the enhanced approach using `create_wide_dataset`, demonstrating how to specify `optional_tables` and `category_filters`. The snippet concludes by showing how the resulting `wide_df` can be passed to further analysis functions, streamlining data preparation. ```python # Traditional approach clif = CLIF(data_dir="/path/to/data") clif.initialize(['patient', 'vitals', 'labs']) # Enhanced with wide dataset wide_df = clif.create_wide_dataset( optional_tables=['vitals', 'labs'], category_filters={'vitals': ['map'], 'labs': ['hemoglobin']} ) # Continue with analysis analysis_results = analyze_wide_dataset(wide_df) ``` -------------------------------- ### Testing Timezone Validation Function Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/05_timezone_handling.ipynb Example of how to call the `validate_timezone_conversion` function with sample data and expected timezone. This snippet demonstrates the practical application of the validation logic. ```Python # Test the validation function # Assuming 'test_datetime_data' and 'eastern_converted' are defined elsewhere # if 'eastern_converted' in locals(): # validation_result = validate_timezone_conversion( # test_datetime_data, # eastern_converted, # 'event_dttm', # 'US/Eastern' # ) ``` -------------------------------- ### Setup and Imports Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/05_timezone_handling.ipynb Imports necessary Python libraries and pyCLIF components for timezone handling and data manipulation. Prints version information and system timezone details. ```Python import sys import os import pandas as pd import numpy as np import pytz from datetime import datetime, timedelta import matplotlib.pyplot as plt import seaborn as sns from zoneinfo import ZoneInfo # Import pyCLIF components from pyclif import CLIF from pyclif.tables.vitals import vitals from pyclif.utils.io import load_data, convert_datetime_columns_to_site_tz print(f"Timezone handling setup complete!") print(f"Python version: {sys.version}") print(f"Pandas version: {pd.__version__}") print(f"Pytz version: {pytz.__version__}") # Display current system timezone print(f"\nSystem timezone info:") print(f"Local time: {datetime.now()}") print(f"UTC time: {datetime.utcnow()}") ``` -------------------------------- ### Initialize CLIF Object Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/01_basic_usage.ipynb Demonstrates initializing the main CLIF class, which requires specifying the data directory, file type (e.g., 'parquet'), and the site's timezone for datetime conversions. It prints the initialized object's configuration. ```python # Set your data directory path - update this to your CLIF data location DATA_DIR = "../src/pyclif/data/clif_demo/" # Initialize CLIF object clif = CLIF( data_dir=DATA_DIR, filetype='parquet', # Your data is in parquet format timezone='US/Eastern' # Your site timezone ) print("CLIF object initialized successfully!") print(f"Data directory: {clif.data_dir}") print(f"File type: {clif.filetype}") print(f"Timezone: {clif.timezone}") ``` -------------------------------- ### Setup and Imports Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/02_individual_tables.ipynb Imports essential Python libraries including sys, os, pandas, datetime, and specific CLIF table classes for patient, vitals, hospitalization, labs, ADT, and respiratory support. Confirms successful import and displays the Python version. ```python import sys import os import pandas as pd from datetime import datetime # Import individual table classes from pyclif.tables.patient import patient from pyclif.tables.vitals import vitals from pyclif.tables.hospitalization import hospitalization from pyclif.tables.labs import labs from pyclif.tables.adt import adt from pyclif.tables.respiratory_support import respiratory_support print(f"Individual table classes imported successfully!") print(f"Python version: {sys.version}") ``` -------------------------------- ### Generate Validation Report Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/03_data_validation.ipynb Example of generating a validation report for loaded data tables. It demonstrates passing a dictionary of table objects to a report generation function. ```python # Generate report for loaded tables tables_for_report = { 'patient': safe_patient, 'vitals': safe_vitals } generate_validation_report(tables_for_report) ``` -------------------------------- ### Initialize CLIF Object and Load Tables Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/README.md Demonstrates initializing the main CLIF class with a data directory, file type, and timezone, then loading specific tables and accessing their data. ```python from pyclif import CLIF # Initialize CLIF object with your data directory clif = CLIF( data_dir="/path/to/your/clif/data", filetype='parquet', # or 'csv' timezone='US/Eastern' # Your site timezone ) # Load specific tables clif.initialize(tables=['patient', 'vitals', 'labs']) # Access loaded data print(f"Patients: {len(clif.patient.df)}") print(f"Vitals records: {len(clif.vitals.df)}") # Check validation status print(f"Patient data valid: {clif.patient.isvalid()}") print(f"Vitals data valid: {clif.vitals.isvalid()}") ``` -------------------------------- ### Pytest Commands Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/README.md Commands for running the project's test suite using pytest. Includes options for coverage reports and verbose output. ```bash # Run all tests pytest ``` ```bash # Run with coverage report pytest --cov=pyclif ``` ```bash # Run specific test module pytest tests/test_patient.py ``` ```bash # Run with verbose output pytest -v ``` -------------------------------- ### Auto-Loading Tables with CLIF Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/docs/wide_dataset.md Demonstrates the automatic loading of required tables by the CLIF function. It shows how to initialize CLIF and create a wide dataset, with optional tables being loaded as needed without explicit manual loading steps. ```python # No need to manually load tables clif = CLIF(data_dir="/path/to/data", filetype='parquet') # Tables will be auto-loaded as needed wide_df = clif.create_wide_dataset( optional_tables=['vitals', 'labs'] # These will be loaded automatically ) ``` -------------------------------- ### Get Range Validation Report Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/02_individual_tables.ipynb Fetches and displays a detailed range validation report for the vitals table. It also demonstrates how to iterate through and print specific issues found in the report if any exist. ```python # Get detailed range validation report range_report = vitals_table.get_range_validation_report() print("Range validation report:") print(range_report) if not range_report.empty: print("\nRange validation issues found:") for _, row in range_report.head(3).iterrows(): print(f" - {row['message']}") ``` -------------------------------- ### Vitals Table: Get Vital Units Mapping Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/02_individual_tables.ipynb Accesses the `vital_units` property of the `vitals_table` object to retrieve a mapping of vital names to their corresponding units. Displays the first five entries of this mapping. ```python # Get vital units mapping vital_units = vitals_table.vital_units print("Vital units mapping:") for vital, unit in list(vital_units.items())[:5]: # Show first 5 print(f" {vital}: {unit}") ``` -------------------------------- ### Create Sample Wide Dataset with pyCLIF Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/07_wide_dataset_creation.ipynb Demonstrates creating a wide dataset using `clif.create_wide_dataset`. This example uses a random sample of 20 hospitalizations, includes 'vitals' and 'labs' optional tables with specific category filters, saves the output to 'sample_wide_dataset.parquet', and prints summary statistics of the generated dataset. ```Python print("=== Example 1: Sample Mode (20 Random Hospitalizations) ===") try: wide_df_sample = clif.create_wide_dataset( optional_tables=['vitals', 'labs'], category_filters={ 'vitals': ['map', 'heart_rate', 'spo2', 'respiratory_rate'], 'labs': ['hemoglobin', 'wbc', 'sodium', 'potassium'] }, sample=True, save_to_data_location=True, output_filename='sample_wide_dataset', output_format='parquet' ) if wide_df_sample is not None: print(f"โœ… Sample wide dataset created with {len(wide_df_sample):,} records and {len(wide_df_sample.columns)} columns") print(f"๐Ÿ‘ฅ Unique hospitalizations: {wide_df_sample['hospitalization_id'].nunique()}") print(f"๐Ÿ“… Date range: {wide_df_sample['event_time'].min()} to {wide_df_sample['event_time'].max()}") # Show column breakdown vital_cols = [col for col in wide_df_sample.columns if col in ['map', 'heart_rate', 'spo2', 'respiratory_rate']] lab_cols = [col for col in wide_df_sample.columns if col in ['hemoglobin', 'wbc', 'sodium', 'potassium']] print(f"\n๐Ÿ“Š Available vital columns: {vital_cols}") print(f"๐Ÿงช Available lab columns: {lab_cols}") else: print("โœ… Sample wide dataset saved to file successfully") except Exception as e: print(f"โŒ Error in Example 1: {str(e)}") import traceback traceback.print_exc()) ``` -------------------------------- ### Show Sample Hourly Data Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/08_hourly_wide_dataset_creation.ipynb Displays a sample of the hourly aggregated ICU data. It selects specific columns relevant for analysis and shows the first 10 rows using pandas. ```python print("\nSample hourly data:") sample_cols = ['hospitalization_id', 'nth_hour', 'day_number', 'hour_bucket', 'map_max', 'heart_rate_mean', 'spo2_mean', 'spo2_min', 'norepinephrine_boolean'] available_cols = [col for col in sample_cols if col in hourly_df.columns] print(hourly_df[available_cols].head(10)) ``` -------------------------------- ### Vitals Table: Get Vital Ranges for Validation Source: https://github.com/common-longitudinal-icu-data-format/pyclif/blob/main/examples/02_individual_tables.ipynb Accesses the `vital_ranges` property of the `vitals_table` object to retrieve the defined ranges used for data validation. Displays the first three vital entries and their associated ranges. ```python # Get vital ranges for validation vital_ranges = vitals_table.vital_ranges print("\nVital ranges for validation:") for vital, ranges in list(vital_ranges.items())[:3]: # Show first 3 print(f" {vital}: {ranges}") ```