Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

Health Analytics with Python: A

Comprehensive Guide for 2024 Van Der


Post
Visit to download the full and correct content document:
https://ebookmass.com/product/health-analytics-with-python-a-comprehensive-guide-f
or-2024-van-der-post/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Financial Architect: Algorithmic Trading with Python: A


comprehensive Guide for 2024 Van Der Post

https://ebookmass.com/product/financial-architect-algorithmic-
trading-with-python-a-comprehensive-guide-for-2024-van-der-post/

Algorithmic Essentials: Trading with Python: Your


Comprehenive Guide for 2024 Van Der Post

https://ebookmass.com/product/algorithmic-essentials-trading-
with-python-your-comprehenive-guide-for-2024-van-der-post/

The Python Advantage: Python for excel in 2024 Hayden


Van Der Post

https://ebookmass.com/product/the-python-advantage-python-for-
excel-in-2024-hayden-van-der-post/

Market Master: Trading with Python Van Der Post

https://ebookmass.com/product/market-master-trading-with-python-
van-der-post/
Power Trader: Options Trading with Python Van Der Post

https://ebookmass.com/product/power-trader-options-trading-with-
python-van-der-post/

Python Fundamentals for Finance: A survey of


Algorithmic Options trading with Python Van Der Post

https://ebookmass.com/product/python-fundamentals-for-finance-a-
survey-of-algorithmic-options-trading-with-python-van-der-post/

Financial Analyst: A Comprehensive Applied Guide to


Quantitative Finance in 2024: A Holistic Guide to:
Python for Finance, Algorithmic Options Trading, Black
Scholes, Stochastic Calculus & More Van Der Post
https://ebookmass.com/product/financial-analyst-a-comprehensive-
applied-guide-to-quantitative-finance-in-2024-a-holistic-guide-
to-python-for-finance-algorithmic-options-trading-black-scholes-
stochastic-calculus-more-van-de/

Data Science With Rust: A Comprehensive Guide - Data


Analysis, Machine Learning, Data Visualization & More
Van Der Post

https://ebookmass.com/product/data-science-with-rust-a-
comprehensive-guide-data-analysis-machine-learning-data-
visualization-more-van-der-post/

Data Universe: Organizational Insights with Python:


Embracing Data Driven Decision Making Van Der Post

https://ebookmass.com/product/data-universe-organizational-
insights-with-python-embracing-data-driven-decision-making-van-
der-post/
H E A LT H
I N F O R M AT I C S
with Python

Hayden Van Der Post

Reactive Publishing
CONTENTS

Title Page
Chapter 1: Introduction to Python in Healthcare
Chapter 2: Intermediate Data Manipulation and Analysis
Chapter 3: Machine Learning in Healthcare
Chapter 4: Genomics and Bioinformatics with Python
Chapter 5: Interoperability and Health Information Exchange
Chapter 6: Data Privacy & Security in Healthcare
Chapter 7: Population Health and Epidemiology
Chapter 8: Clinical Trials and Research
Epilogue
Additional Resources
CHAPTER 1:
INTRODUCTION TO
PYTHON IN
HEALTHCARE

T
he journey of Python within health data science truly began in the late
2000s, when the explosion of data transformed the healthcare sector.
The need for a language that could handle vast datasets, while being
flexible and easy to learn, made Python the ideal candidate. Consequently,
Python's adoption was not just an evolution—it was a revolution in how
healthcare data was analysed and interpreted.

Around the turn of the decade, several pivotal libraries were introduced,
bolstering Python's position as the lingua franca of data science. NumPy
brought efficient array computation, while pandas facilitated data
manipulation and analysis with dataframes—structures ideally suited to
handling medical datasets. Matplotlib and later seaborn provided powerful
visualization tools, essential for discerning patterns and correlations in
clinical data.

As the adoption of electronic health records (EHRs) became commonplace,


Python proved indispensable. Researchers and clinicians required tools to
parse and scrutinize this new wealth of digital health information. Python's
libraries like PyDicom for reading DICOM files, a standard for medical
imaging, and libraries for processing EHRs like FHIR, became integral to
the healthcare data workflow.

The era of big data brought with it machine learning, and Python was once
again ahead of the curve. Scikit-learn, TensorFlow, and Keras enabled even
those with a nascent understanding of machine learning principles to build
predictive models. Models that could foresee patient outcomes, optimise
treatment pathways, and even identify potential epidemics became a reality,
constructed from the foundation Python offered.

One cannot discuss Python's role in health data science without


acknowledging its impact during global crises. During the COVID-19
pandemic, Python was instrumental in modeling the spread of the virus,
analysing its genomic sequence, and managing the deluge of data that
inundated health systems. Real-time dashboards and statistical models,
often developed in Python, informed policy decisions and public health
responses that saved lives.

In Vancouver, a city renowned for its tech scene, Python was used to
amalgamate data from disparate health systems, helping to manage the
caseloads in hospitals during the pandemic. Local data scientists used
Python to build predictive models that informed resource allocation, such as
ventilators and hospital beds, which were critical during the peaks of the
healthcare crisis.

Today, Python's influence continues to grow as health data science dives


into new frontiers like genomics, precision medicine, and neural network-
driven diagnostics. Its evolution is characterized by a symbiotic relationship
with the healthcare sector: Python advances, and health data science finds
new horizons to explore.

Emergence of Python in Data Science

The emergence of Python as a powerhouse in data science is a tale of


serendipity and strategic foresight. It began quietly, as academic institutions
and a few forward-thinking enterprises started to experiment with Python's
potential for data analysis tasks. Initially overshadowed by stalwarts like R
and MATLAB, Python's journey in the data science world was not meteoric
but marked by steady, persistent growth.

Python's user-friendly syntax appealed to non-programmers, including


statisticians and analysts, who found its readability conducive to rapid
learning and application. This was particularly advantageous as the data
science discipline itself was evolving, requiring professionals who could
bridge the gap between statistical theory and computational practice.

The tipping point for Python's rise in the data science community was the
development and improvement of several key libraries tailored to data
analysis and scientific computing. The SciPy ecosystem, which included
NumPy for numerical operations and pandas for data wrangling, provided
the foundational tools necessary for data scientists to transition from theory
to practice with ease.

Moreover, the language's interoperability and its ability to glue disparate


systems together made it a favorite for integrated data science workflows.
As open-source software, Python encouraged collaboration and sharing,
which rapidly accelerated the development of a rich ecosystem of data
science libraries and frameworks.

In the context of healthcare, Python's ascendancy was bolstered by the


specific demands of medical data analysis. The healthcare industry required
a tool that could handle the complexities of medical data, from varied data
types like imaging and genomic sequences to time-series data from patient
monitoring devices. Python's simplicity and the rich suite of libraries, such
as BioPython for biological computations and PyHealth for healthcare
analytics, made it an ideal fit for the domain.

The capacity of Python to deal with large datasets, a staple in the healthcare
industry, further cemented its position. Libraries like Dask and Vaex
extended Python's ability to work with "big data", enabling the analysis of
datasets too large to fit into a single machine's memory, without the need for
complex distributed computing setups.
Python's contribution to data science became conspicuously evident during
global health crises, where rapid data analysis was crucial. Its role in
streamlining data flows, from collection and cleaning to modeling and
visualization, allowed health professionals and decision-makers to respond
to critical situations with unprecedented agility.

In the classroom and the lab, Python became the teaching language of
choice, shaping new generations of data scientists. Its pragmatism and
versatility prepared students for the real-world challenges they would face,
particularly in the multifaceted landscape of health data science.

As Python's prominence in data science grew, so did the platforms


supporting it. Jupyter Notebooks emerged as a popular interactive
environment, allowing data scientists to combine executable code with
narrative text and visualizations. This proved invaluable in sharing research
findings, educating peers, and streamlining collaborative projects in both
academic and healthcare settings.

Understanding Basic Data Types: Strings, Integers, Floats

In Python programming for healthcare data science, an astute


understanding of basic data types is imperative. These foundational types
are the atoms of the data universe, forming the substance from which
complex data structures and nuanced analysis are crafted.

Strings, encapsulated within either single (' ') or double (" ") quotes, are
sequences of characters representing textual data. In healthcare data
science, strings are omnipresent, encompassing anything from patient
names to diagnostic codes. They enable the representation of non-numeric
data within a dataset, a crucial feature considering the extensive use of text
in medical records, prescriptions, and notes.

Consider a patient's record that contains a string "Diabetes Mellitus Type 2"
as a diagnosed condition. This text, stored as a string, becomes a key piece
of data for analysis, classification, and potential alignment with treatment
protocols. Python provides a multitude of methods to manipulate and
process strings, such as `split()`, `replace()`, and `upper()`, which can be
leveraged to standardize and prepare textual data for further data science
tasks.

Integers are whole numbers without a decimal point. In healthcare datasets,


integers are used to represent discrete data such as the number of hospital
admissions, patient room numbers, or the count of a particular type of white
blood cell. An understanding of integers is essential, as they are frequently
used in statistical models and calculations across health data analysis.

For instance, when dealing with patient age demographics, integers provide
a clear and concise representation that can be easily compared and
calculated upon. Python's innate ability to handle arithmetic operations with
integers allows for efficient computation when assessing metrics like the
average age of patients with a certain condition or the distribution of ages
within a study population.

Floats, the third basic data type, are numbers that include a decimal point.
They are vital for representing continuous measurements in medical data,
such as body mass index (BMI), blood pressure readings, or medication
dosages. These values require the precision that floats offer, especially
when the difference of small decimals can significantly impact a patient's
health outcome.

Take, for example, the administration of a drug where dosage needs to be


calculated based on patient weight; floats allow for the precision needed in
this calculation. With Python's float division, even when both operands are
integers, a float result is returned, ensuring precise outcomes in every
calculation.

Both integers and floats fall under the wider category of numbers within
Python, and they can be freely converted between each other to suit the
needs of different datasets. This flexibility is fundamental for health data
scientists, who must frequently normalize data and convert between
measurements units.

Complex Data Structures: Lists, Tuples, Dictionaries, and Sets


In the analytical orchestra that is Python programming for health data
science, complex data structures are the ensembles that harmonize disparate
elements into a coherent symphony of information. As we dive into these
structures, we unveil their unique characteristics and their indispensable
role in organizing, storing, and manipulating data efficiently.

Lists in Python are mutable sequences, capable of storing an ordered


collection of items, which can be of different data types. In healthcare data
science, lists are akin to versatile containers, ideal for housing sequential
data such as patient vitals over time or a series of laboratory test results.

Imagine a scenario involving the tracking of a patient's cholesterol levels. A


list allows for the appending of new data points as they are received, the
convenient retrieval of any specific measurement, and the easy sorting of
results for trend analysis. Lists also support comprehensive slicing, enabling
health data scientists to segment sequences for focused investigations.

For exemplification:

```python
cholesterol_levels = [200, 189, 204, 199, 178]
cholesterol_levels.sort() # Sorting to find trends
print(cholesterol_levels)
```

Tuples are immutable sequences, which means once they are created, their
content cannot be altered. This quality makes tuples reliable vessels for
fixed data groupings such as the coordinates of a hospital's location or the
date of a patient's discharge.

Tuples bring forth a level of data integrity, as their immutability prevents


accidental alteration—a crucial feature when dealing with sensitive health
information that must remain unmodified for legal and ethical reasons.

An example of a tuple might be:


```python
hospital_location = (49.2827, -123.1207) # Latitude and longitude of
Vancouver General Hospital
discharge_date = (2023, 3, 14) # Year, Month, Day
```

Dictionaries are Python's built-in mapping type. They are unordered


collections of items where each item is a key-value pair. Dictionaries are
ideal for associating related information, like linking patient IDs to their
records or mapping medications to their dosages.

In health informatics, dictionaries facilitate the quick retrieval of


information based on unique identifiers—critical in environments where
rapid access to patient-specific data can be life-saving.

A simple dictionary example:

```python
patient_medication_dosage = {'Metformin': 500, 'Atorvastatin': 20}
print(patient_medication_dosage['Metformin']) # Outputs: 500
```

Sets are unordered collections of unique elements. In the context of health


data, sets are useful for eliminating duplicates, which is beneficial when
compiling unique lists of symptoms, medications, or diseases from a larger
dataset.

Sets inherently support mathematical set operations like union, intersection,


and difference, enabling health data scientists to perform analysis on
distinct groups of data effectively.

Utilizing a set to identify unique conditions:

```python
patient_conditions = set(['Hypertension', 'Diabetes', 'Hypertension'])
print(patient_conditions) # Outputs: {'Hypertension', 'Diabetes'}
```

Each of these complex data structures—lists, tuples, dictionaries, and sets—


serves a distinct purpose and offers a toolset for solving specific problems
within the vast domain of health data science. Whether you are constructing
patient profiles, managing clinical trial data, or tracking epidemiological
trends, understanding and leveraging these structures is fundamental to
effective data management and insightful analysis.

Handling Healthcare-Specific Data Structures: FHIR, HL7

In health informatics, data interoperability is not just a technical


requirement; it's a conduit for continuity of care, patient safety, and clinical
research. Healthcare-specific data structures such as Fast Healthcare
Interoperability Resources (FHIR) and Health Level Seven (HL7) are the
lingua franca enabling diverse health information systems to converse
seamlessly.

FHIR is a standard describing data formats and elements (known as


"resources") and an application programming interface (API) for
exchanging electronic health records. FHIR is built on modern web
technologies and is designed for ease of implementation and integration. It
thrives on simplicity and extensibility, making healthcare data exchange
more intuitive and efficient.

The following Python snippet demonstrates how one might interact with a
FHIR API to retrieve a patient's record:

```python
import requests

fhir_endpoint = "https://fhirtest.uhn.ca/baseDstu3/Patient/845439"
response = requests.get(fhir_endpoint)
patient_data = response.json()
print(patient_data['name']) # Accessing the patient's name from the FHIR
response
```

HL7, specifically HL7 Version 2.x, is a set of international standards for the
transfer of clinical and administrative data between software applications
used by various healthcare providers. These standards focus on the
application layer, which is "layer 7" in the OSI model. HL7 helps to
simplify the implementation of interfaces among healthcare systems and
reduce the complexity of healthcare data integration.

Parsing an HL7 message to extract patient information might look like this:

```python
import hl7

# An example HL7 message


hl7_message =
"MSH|^~\&|HIS|RAD|LAB|CARDIO|202303141605||ADT^A01|MSG0000
1|P|2.6\rEVN|A01|202303141605\rPID|||545776^^^HIS||SMITH^JOHN^A||
19600407|M||C|1200 N ELM STREET^^GREENSBORO^NC^27401-
1020|GL|(919)379-1212|(919)271-
3434||S||545776|123456789|987654^NC\r"

# Parse the message


message = hl7.parse(hl7_message)
for segment in message:
if segment[0] == 'PID':
patient_info = segment
print(f"Patient's Name: {patient_info[5]}") # Outputs: Patient's
Name: SMITH^JOHN^A
```

Both FHIR and HL7 play pivotal roles in the management of health data—
they encapsulate patient information, clinical observations, diagnostic
reports, and treatment outcomes, all of which are essential for a
comprehensive understanding of a patient's health narrative.

However, the complexities of these data structures lie not only in their
syntax but also in their semantic layers—where the meaning of the data is
encoded in the relationships between the elements. It requires a
multifaceted approach to handle these data structures proficiently: a
thorough understanding of the standards, an ability to navigate or construct
APIs, and a keen sense for data quality and integrity.

As health data scientists, the ability to parse, manipulate, and compose


FHIR and HL7 messages with Python opens a multitude of possibilities for
system integration, data analysis, and, for transforming the quality and
delivery of healthcare. The upcoming sections of this book will dive deeper
into practical applications and the nuances of these healthcare-specific data
structures, offering readers an actionable understanding of how to harness
their full potential in the pursuit of health data excellence.

Data Type Conversion and Manipulation Techniques

The versatility of Python in handling various data types is crucial when


dealing with the heterogeneity of healthcare data. A deep dive into data type
conversion and manipulation techniques reveals the transformative power
these processes have on data analysis, especially when data comes from
disparate sources and formats.

Data Type Conversion in Python is a fundamental skill for health data


scientists. In healthcare datasets, numerical and categorical data often
coexist, and the ability to convert between data types is necessary for
effective data preparation and analysis. Python's dynamic typing allows for
effortless data type conversion, enhancing the fluidity with which one can
clean and preprocess healthcare data.
Let us explore how Python facilitates these transformations:

```python
# Convert string to float
blood_pressure = "120.5"
blood_pressure_value = float(blood_pressure)

# Convert integer to string


patient_id = 12345
patient_id_str = str(patient_id)

# Convert a list of strings to a list of integers


age_years = ["35", "42", "58"]
age_years_int = list(map(int, age_years))
```

Manipulating Data Types is just as critical. The manipulation of lists,


dictionaries, and dataframes is commonplace in Python-driven healthcare
analytics. For instance, when working with patient records stored in lists or
dictionaries, one might need to add, remove, or update entries as new data
becomes available or corrections are made.

Consider the following example, which simulates updating a patient's


record:

```python
patient_record = {
'name': 'John Smith',
'age': 45,
'blood_type': 'O+',
'allergies': ['Penicillin', 'Peanuts']
}
# Updating the age
patient_record['age'] = 46

# Adding a new allergy


patient_record['allergies'].append('Aspirin')

# Removing an incorrect allergy


patient_record['allergies'].remove('Peanuts')
```

Dataframes, the cornerstone of the pandas library, are especially powerful


for tabular data manipulation. They allow for operations on entire columns
or rows, conditional selection, and complex joins and merges. The
following snippet showcases a basic dataframe operation:

```python
import pandas as pd

# Create a dataframe from a dictionary


df = pd.DataFrame({
'patient_id': [1, 2, 3],
'blood_pressure': [120, 135, 110],
'cholesterol': [190, 220, 185]
})

# Convert blood pressure to a categorical variable


df['bp_category'] = pd.cut(df['blood_pressure'], bins=[0, 120, 140, 190],
labels=['Normal', 'Elevated', 'High'])
```

Through these examples, one can appreciate the elegant simplicity with
which Python handles diverse data types and the robustness it offers in data
manipulation.

Memory Management for Large Health Datasets

In the domain of health data science, the proficient management of memory


is paramount, particularly when confronted with the colossal datasets that
characterize contemporary healthcare research and practice. The handling
of large datasets with aplomb is a testament to the judicious use of Python's
facilities, engineered to be both powerful and efficient.

Efficient Memory Usage entails the employment of strategies to minimize


memory consumption without compromising the speed or accuracy of data
analysis. Python provides numerous avenues for this, and one especially
potent tool in the health data scientist's arsenal is the use of `pandas` library
with its well-optimized data structures.

Consider the use of `dtype` optimization for reducing memory footprint:

```python
import pandas as pd

# Load a large dataset of patient records


patient_data = pd.read_csv('large_health_dataset.csv')

# Optimize memory usage by downcasting numerical columns


float_cols = patient_data.select_dtypes(include=['float']).columns
int_cols = patient_data.select_dtypes(include=['int']).columns

patient_data[float_cols] = patient_data[float_cols].apply(pd.to_numeric,
downcast='float')
patient_data[int_cols] = patient_data[int_cols].apply(pd.to_numeric,
downcast='integer')
```
In such a procedure, the application of `downcast` to 'float' and 'integer' can
significantly reduce the memory footprint of the dataset by fitting the data
into the most appropriate and compact numerical dtype available.

Data Chunking is another technique that shines when manipulating


extensive datasets that cannot be readily accommodated in memory. By
partitioning the dataset into manageable pieces, one can iteratively process
and analyze the data.

A demonstration of chunking a dataset using `pandas`:

```python
chunk_size = 5000 # This can be adjusted based on the available memory
chunks = []

for chunk in pd.read_csv('large_health_dataset.csv',


chunksize=chunk_size):
# Perform data manipulation on the chunk
processed_chunk = process_data(chunk)
chunks.append(processed_chunk)

# Concatenate the processed chunks back into a single dataframe


full_dataset = pd.concat(chunks, ignore_index=True)
```

In-Memory Compression techniques, such as those offered by `bcolz` or


`PyTables`, are also essential for dealing with voluminous health datasets.
These libraries can store data in a compressed format, which both reduces
memory usage and accelerates processing time due to lesser I/O operations.

Efficient Data Storage Formats such as HDF5 or Parquet, when paired with
Python, allow for sophisticated on-disk storage while still providing the
capabilities for fast reading and writing operations, which is pivotal in the
context of large-scale health data.
```python
# Write a DataFrame to a Parquet file
df.to_parquet('patient_data.parquet')

# Read the Parquet file back into a pandas DataFrame


df = pd.read_parquet('patient_data.parquet')
```

Through judicious use of these memory management techniques, health


data scientists can conduct analyses that might otherwise be hampered by
the limitations of system memory. The upcoming segments will continue to
elucidate advanced strategies for working with substantial health datasets,
ensuring that the reader is well-equipped for the rigorous demands of health
informatics.

The Art and Science of Loading Health Datasets with Python

As we pivot our focus to the initial stages of data analysis, it becomes


evident that the foundational act of loading health datasets into Python is
both an art and a science. It requires a meticulous balance of technical
knowledge and a nuanced understanding of the data's intricacies.

Loading and Inspecting Health Datasets with Pandas

To initiate our practical exploration, let us consider the import of a dataset


containing patient laboratory results. The CSV file format is ubiquitously
used for its simplicity and widespread compatibility with various tools and
platforms.

```python
import pandas as pd

# Importing the dataset


lab_results = pd.read_csv('patient_lab_results.csv')
# Display the initial few records to establish familiarity
print(lab_results.head())
```

The `head()` method is instrumental in providing a sneak peek into the


dataset, revealing the initial rows and allowing for a preliminary assessment
of the data structure at a glance. With healthcare data often varying in
quality, the initial inspection is a crucial step that informs the strategy for
cleaning and preprocessing.

The next stage in our inspection is to perform a thorough quality check,


utilizing Pandas' functionality to summarize the dataset, thus unveiling any
apparent issues or peculiarities such as missing values, which are
particularly troublesome in health data due to the potential impact on
patient outcomes.

```python
# Dataset summary, including non-null values and data types
print(lab_results.info())

# Identify columns with missing values


missing_values = lab_results.isnull().sum()
print(missing_values[missing_values > 0])
```

Upon pinpointing the columns with missing values, we can strategize on


approaches to handle these effectively, whether through imputation
techniques or by consulting clinical experts on the best course of action.

Exploratory data analysis continues as we dive deeper into the dataset's


numerical summaries, particularly for variables that are critical indicators of
health outcomes, such as cholesterol levels or blood pressure readings.

```python
# Statistical summary of numerical features
print(lab_results.describe())
```

Descriptive statistics provide a quantitative summary, but for a more


nuanced understanding, visual exploration is invaluable. Pandas interfaces
gracefully with visualization libraries such as Matplotlib and Seaborn to
graphically represent the data, aiding in identifying trends or outliers that
could signify data quality issues or real clinical phenomena.

```python
import matplotlib.pyplot as plt
import seaborn as sns

# Visualizing the distribution of cholesterol levels


sns.histplot(lab_results['cholesterol_level'], kde=True)
plt.title('Distribution of Cholesterol Levels')
plt.xlabel('Cholesterol Level')
plt.ylabel('Frequency')
plt.show()
```

This graphical depiction helps us discern the distribution of cholesterol


levels, which is often skewed in the general population, reflecting the
propensity for cardiovascular diseases.

Data Cleaning and Preprocessing Techniques

The data cleaning journey commences with addressing inconsistencies and


errors that inherently mar health datasets. We shall illustrate this essential
process through a Python-driven approach, harnessing Pandas and its
cohorts in the data science toolkit.
Initially, we confront the ubiquitous challenge of missing data. Healthcare
datasets are notoriously prone to this issue due to myriad factors, from non-
response in surveys to omitted entries in electronic health records. The
strategy for handling such voids must be clinically sound and statistically
robust.

```python
# Handling missing data
lab_results.fillna(method='ffill', inplace=True)
```

In the above snippet, the forward-fill method propagates the last observed
non-null value to the next null occurrence within the column. This
technique assumes temporal or logical continuity, which might be
appropriate for certain types of health data, like continuous monitoring of
vital signs.

Next, we turn our attention to erroneous entries and outliers. These


aberrations can arise from transcription errors or anomalies in clinical
readings. Detecting outliers is not merely a statistical exercise but a clinical
one, as some may represent significant but genuine health events.

```python
from scipy import stats

# Z-score for outlier detection


z_scores = np.abs(stats.zscore(lab_results._get_numeric_data()))
outliers = (z_scores > 3)
lab_results_clean = lab_results[~outliers.any(axis=1)]
```

Utilizing the Z-score method, we identify and exclude data points that
deviate markedly from the mean. This exclusion must be judiciously
applied, ensuring that clinically relevant outliers are scrutinized rather than
discarded indiscriminately.

Another vital aspect of preprocessing is data type conversion. Many


algorithms require numerical input, necessitating the conversion of
categorical variables into a numerical format—a process known as one-hot
encoding.

```python
# One-hot encoding for categorical variables
lab_results_encoded = pd.get_dummies(lab_results_clean, drop_first=True)
```

The `get_dummies` function metamorphoses categorical variables into a


binary matrix representation, an essential step towards preparing the dataset
for machine learning models.

Moreover, data normalization is a critical step, particularly in health data


where variable scales can vary dramatically—think of enzyme levels versus
blood pressure readings.

```python
from sklearn.preprocessing import StandardScaler

# Normalizing numerical variables


scaler = StandardScaler()
lab_results_scaled = scaler.fit_transform(lab_results_encoded)
lab_results_normalized = pd.DataFrame(lab_results_scaled,
columns=lab_results_encoded.columns)
```

The `StandardScaler` from scikit-learn standardizes the features by


removing the mean and scaling to unit variance, ensuring that no single
variable unduly influences the model due to its scale.
These preprocessing steps constitute the meticulous craft of data
preparation. Such attention to detail ensures the data's readiness for the
analytical rigor that follows. The subsequent sections will further explore
the multifaceted process of turning data into decisions, weaving through the
intricacies of healthcare data science where meticulous preparation meets
thoughtful analysis.

Descriptive Statistics for Health Data Analysis

Commencing on this analytical voyage, we define our central tendencies—


the mean, median, and mode—which provide us with a snapshot of the
data's distribution. Each measure offers unique insights, with the mean
providing the arithmetic average, the median indicating the middle value,
and the mode representing the most frequent occurrence.

```python
# Calculating central tendencies
mean_age = patient_data['Age'].mean()
median_age = patient_data['Age'].median()
mode_age = patient_data['Age'].mode()[0]
```

The snippet above demonstrates the simplicity with which Python, through
the Pandas library, allows us to calculate these measures for a hypothetical
'Age' column in a dataset. These measures serve as the stepping stones to
deeper analysis.

We then examine the spread of our data through measures of variability


such as the range, interquartile range (IQR), variance, and standard
deviation. These metrics offer a window into the diversity and distribution
of our health data points.

```python
# Measures of variability
range_age = patient_data['Age'].max() - patient_data['Age'].min()
iqr_age = patient_data['Age'].quantile(0.75) -
patient_data['Age'].quantile(0.25)
variance_age = patient_data['Age'].var()
std_dev_age = patient_data['Age'].std()
```

By calculating the range, we observe the breadth of our data's span. The
IQR tells us about the middle 50%, providing a sense of a dataset's central
spread. Variance and standard deviation give us an understanding of how
much our data varies from the mean.

It is also crucial to understand the shape of our data distribution, which is


where skewness and kurtosis come into play. Skewness measures the
asymmetry of the distribution, while kurtosis indicates the 'tailedness'—the
presence of outliers.

```python
# Distribution shape metrics
skewness_age = patient_data['Age'].skew()
kurtosis_age = patient_data['Age'].kurtosis()
```

In the healthcare context, a positive skew might indicate an aging patient


population, while high kurtosis could suggest the presence of extreme
health events or measurement errors.

As we journey through the landscape of health data, descriptive statistics


also call upon graphical representations such as histograms, box plots, and
scatter plots to visually communicate the distribution and relationships
within data.

```python
import matplotlib.pyplot as plt
import seaborn as sns

# Visualizing the distribution of ages


plt.figure(figsize=(10, 6))
sns.histplot(patient_data['Age'], bins=30, kde=True)
plt.title('Age Distribution of Patients')
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.show()
```

The code above employs Seaborn and Matplotlib to craft a histogram


supplemented with a Kernel Density Estimate (KDE) that allows us to
observe the distribution of ages within a patient dataset visually. Similarly,
box plots can highlight outliers, and scatter plots can elucidate correlations
between variables.

Data Visualization Using Matplotlib and Seaborn in the Health Context

Upon the scaffold of descriptive statistics, we erect the visual edifices that
transform raw data into clear, actionable insights. In the world of health
data science, adept use of visualization tools like Matplotlib and Seaborn is
not just useful—it is imperative. It allows practitioners to elucidate patterns,
identify anomalies, and communicate complex findings with intuitive
clarity.

Within the Python ecosystem, Matplotlib is the venerable foundation upon


which many visualization libraries are built. It offers immense flexibility
and control, allowing for the creation of simple line plots to complex multi-
panel layouts. Seaborn, built on top of Matplotlib, extends its capabilities,
providing a more aesthetically pleasing interface and additional plot types
designed for statistical exploration.
Let us consider a scenario where we aim to visualize the age distribution of
a patient cohort affected by a specific condition. The visualization not only
informs about common age-related trends but also brings to light any
significant deviations that may warrant further investigation.

```python
import matplotlib.pyplot as plt
import seaborn as sns

# Set the aesthetic style of the plots


sns.set_style("whitegrid")

# Creating a histogram with Seaborn to visualize age distribution


plt.figure(figsize=(12, 6))
sns.histplot(data=patient_data, x='Age', hue='Condition', multiple="stack",
palette="viridis")
plt.title('Stacked Histogram of Patient Age by Condition')
plt.xlabel('Age')
plt.ylabel('Number of Patients')
plt.legend(title='Condition')
plt.tight_layout()
plt.show()
```

The code above generates a stacked histogram that not only reveals the
distribution of ages but also segments it by the condition, allowing quick
visual differentiation between patient groups. The 'viridis' color palette is
chosen for its perceptual uniformity, ensuring that the visualization is
interpretable by those with color vision deficiencies.

Further, in health data science, it is often necessary to compare multiple


variables to uncover relationships that could be critical for diagnosis or
treatment strategies. A jointplot provides a bivariate scatterplot along with
univariate histograms within the same figure, offering a composite view.

```python
# Jointplot of Age and Cholesterol Levels
sns.jointplot(data=patient_data, x="Age", y="Cholesterol_Level",
kind="scatter", color='coral')
plt.suptitle('Scatterplot of Cholesterol Levels by Age',
verticalalignment='top')
plt.tight_layout()
plt.show()
```

The jointplot created with Seaborn allows us to observe the relationship


between patients' ages and their cholesterol levels. Such insights could be
instrumental in developing age-specific screening protocols or targeted
interventions.

In a healthcare setting, time is often a critical factor, and line plots can track
changes in health metrics over time. Utilizing Matplotlib's plotting
capabilities, we can create a line plot that tracks the progression of a health
metric, such as average blood pressure readings, over several months.

```python
# Line plot of average monthly blood pressure readings
plt.figure(figsize=(14, 7))
plt.plot(patient_data['Month'], patient_data['Average_BP'], marker='o',
linestyle='-', color='indigo')
plt.title('Monthly Trend of Average Blood Pressure Readings')
plt.xlabel('Month')
plt.ylabel('Average Blood Pressure')
plt.grid(True)
plt.show()
```

The line plot above offers a temporal dimension, revealing trends such as
seasonal variations in blood pressure, which could prompt further inquiry
into environmental or behavioral factors.

These visualizations serve as fundamental instruments, making opaque


numerical data transparent, and allowing the eye to observe what the mind
might otherwise miss. It is through these visual narratives that health data
scientists can make a profound impact, translating abstract numbers into
concrete decisions that can save lives.

Exploratory Data Analysis (EDBest Practices for Health Datasets

In the landscape of health data science, exploratory data analysis (EDis akin
to the reconnaissance mission before a full-scale engagement. It is during
this stage that data scientists, like medical detectives, sift through the sand
of datasets to uncover the pearls of insight that lie beneath. EDA is crucial,
as it informs the subsequent steps of model building, feature selection, and,
the decision-making processes in healthcare.

The best practices for EDA in health data science are not merely technical
procedures; they are a blend of statistical scrutiny, domain expertise, and an
understanding of the end goal—improving patient outcomes. Below are key
considerations that underscore the EDA process:

1. Data Quality Assessment: Begin by assessing the completeness and


accuracy of the dataset. Health datasets often come from various sources
and may contain errors, inconsistencies, or missing values that need to be
addressed. Tools like pandas Profiling in Python can automate much of this
initial data quality assessment.

2. Variable Identification: Recognize and classify variables into numerical


or categorical, dependent or independent. This step shapes the analysis
strategy and lays out the structure for further investigation.
3. Univariate Analysis: For each variable, perform univariate analysis. Plot
histograms or boxplots for continuous variables to understand distribution
and identify outliers. For categorical variables, frequency counts or bar
charts reveal the distribution across categories.

4. Bivariate Analysis: Conduct bivariate analysis to discover relationships


between variables. Scatter plots, correlation matrices, and cross-tabulations
can help to detect potential associations or confounding factors that may
affect health outcomes.

5. Handling Missing Data: Develop strategies for dealing with missing data,
as it can skew analysis and model performance. Options include imputation,
using algorithms that can handle missing values, or dropping the missing
data, depending on the situation and the amount of data missing.

6. Temporal Analysis: Time series analysis is pivotal in healthcare EDA due


to the longitudinal nature of patient data. Python's pandas library offers
functionality to handle time series data effectively—analyzing trends,
detecting seasonality, and decomposing time series can unveil temporal
patterns in health data.

7. Text Data Handling: Clinical notes and reports are rich with information
but come in unstructured text form. Employ natural language processing
(NLP) techniques to extract features from this text data, which can be
crucial for diagnoses or treatment plans.

8. Feature Engineering: Create new features from existing data that could
have predictive power or could help in understanding the structure within
the data. For instance, calculating the Body Mass Index (BMI) from height
and weight could be more informative than considering them separately.

9. Dimensionality Reduction: Health datasets can be large and complex.


Use techniques like Principal Component Analysis (PCto reduce the
number of variables and to uncover latent features that capture the essence
of the data.
10. Data Visualizations: Select the appropriate visualization tools to
uncover patterns, anomalies, or relationships within the data. Use Python
libraries like seaborn for sophisticated plots and bokeh or plotly for
interactive visualizations that can reveal deeper insights when interacted
with.

```python
# Example of a correlation heatmap in seaborn
plt.figure(figsize=(10, 8))
correlation_matrix = patient_data.corr()
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm')
plt.title('Correlation Heatmap of Patient Data Variables')
plt.show()
```

The example above demonstrates a correlation heatmap, an essential


visualization in EDA. It highlights the relationships between different
health data variables, helping to discern which factors might influence
patient outcomes.

Each of these steps, executed with the precision and foresight characteristic
of seasoned health data scientists, feeds into a robust EDA framework that
sets the stage for solid predictive modeling. As we harness these best
practices, we not only refine our datasets but also sharpen the tools of our
trade, ensuring that the insights garnered carry the potential to inform and
transform healthcare delivery.

Ethics, Privacy, and Legal Considerations in Health Data Science

As we navigate the digital topography of health data science, it becomes


increasingly evident that the collection, analysis, and application of health
data are not merely acts of scientific inquiry but are underpinned by a
mosaic of ethical, privacy, and legal considerations. Grappling with these
considerations demands a conscientious approach that respects individual
rights while advancing collective health benefits.

Ethical Foundations: The ethical bedrock of health data science is built on


the principles of beneficence, non-maleficence, autonomy, and justice.
When managing health datasets, we must ensure that our endeavors aim to
do good, avoid harm, respect patient autonomy, and promote equity. We
must consider the implications of algorithmic bias, the repercussions of
data-driven decisions on patient care, and the societal ramifications of our
analytical outcomes.

Privacy Preservation: Privacy concerns in health data science are


paramount, with sensitive information often requiring rigorous safeguards.
We dive into practices such as anonymization and de-identification, which
strip datasets of personally identifiable information, thereby protecting
patient confidentiality. However, the challenge persists in maintaining data
utility while ensuring privacy—a balance that necessitates the application of
techniques like differential privacy.

Legal Landscape: The legal landscape within which health data science
operates is characterized by complexity and constant evolution. Legislation
such as the Health Insurance Portability and Accountability Act (HIPAin
the United States, the General Data Protection Regulation (GDPR) in
Europe, and other international frameworks dictate stringent compliance
requirements for data handling and breaches. We must navigate these
legalities with a clear understanding of consent, data governance, and the
repercussions of non-compliance.

```python
# Example: De-identifying a dataset in pandas
def deidentify_data(df, columns_to_remove):
"""
This function takes a DataFrame and a list of columns to remove for de-
identification purposes.
"""
df_deidentified = df.drop(columns=columns_to_remove)
return df_deidentified

# Deidentify the dataset by removing 'Name' and 'SSN' (Social Security


Number)
columns_to_deidentify = ['Name', 'SSN']
deidentified_patient_data = deidentify_data(patient_data,
columns_to_deidentify)
```

The snippet above is an instance of practical Python application for de-


identification, showcasing how we can strip away personal identifiers from
health datasets to preserve patient privacy.

As we wade through the ethical quagmire and confront privacy dilemmas,


the legal guidelines serve as our compass, ensuring that our scientific
explorations do not lead us astray from our moral and legal obligations. It is
through rigorous adherence to these principles that we can harness the
power of health data science to impact healthcare positively while
maintaining the trust and integrity that the field necessitates.

The Crucial Intersection of HIPAA and PHI in Health Data Science

HIPAA, a pivotal piece of U.S. legislation enacted in 1996, has far-reaching


implications for anyone involved in handling health data. Its primary goal is
to safeguard the privacy and security of individuals' medical information
while allowing the flow of health data necessary to provide high-quality
healthcare and protect the public's health and well-being.

Protected Health Information (PHI): PHI encompasses a wide array of


information, including patients' medical records, health histories, lab test
results, and insurance information. Under HIPAA, PHI is defined as any
information about health status, healthcare provision, or payment for
healthcare that can be linked to an individual. This definition applies to
information across all mediums—electronic, paper, and oral.

Ensuring Compliance: For data scientists, ensuring HIPAA compliance


involves a multi-faceted approach. This includes the implementation of
physical, administrative, and technical safeguards. Physical safeguards
relate to the protection of electronic systems and buildings. Administrative
actions involve policies and procedures designed to clearly show how the
entity complies with HIPAA. Technical safeguards, perhaps most pertinent
to data scientists, refer to the technology and the policy and procedures for
its use that protect PHI and control access to it.

```python
# Example: Securing PHI in a Python environment using encryption
from cryptography.fernet import Fernet

# Generate a key for encryption and decryption


fernet_key = Fernet.generate_key()

cipher_suite = Fernet(fernet_key)

def encrypt_phi(data):
"""
This function encrypts PHI data using Fernet symmetric encryption.
"""
encrypted_data = cipher_suite.encrypt(data.encode('utf-8'))
return encrypted_data

# Encrypt PHI data before storing or sharing


phi_data = "Patient treatment details and payment information"
encrypted_phi_data = encrypt_phi(phi_data)

print("Encrypted PHI Data:", encrypted_phi_data)


```

The Python code provided exemplifies a practical method to encrypt PHI


data, ensuring that even if unauthorized access to data occurs, the
information remains unintelligible and secure.

The Role of Data Scientists in HIPAA Compliance: Data scientists in


healthcare must have a robust understanding of HIPAA and PHI to navigate
the intricacies of compliance. This includes knowledge of the 'Minimum
Necessary Rule,' which prescribes that only the minimum necessary PHI
needed to accomplish the intended purpose of the use, disclosure, or request
should be accessed or disclosed.

Moreover, data scientists must grasp the nuances of the 'Privacy Rule,'
which sets standards for the protection of individuals' medical records and
other PHI by three types of covered entities: health plans, healthcare
clearinghouses, and healthcare providers who conduct standard healthcare
transactions electronically.

The interplay between HIPAA and PHI highlights the critical role that data
scientists play in protecting patient information. By employing advanced
encryption techniques, ensuring secure data storage and transfer, and
staying abreast of regulatory changes, data scientists can ensure that their
practices not only yield valuable insights but also safeguard the information
entrusted to them.

Navigating the Labyrinth of Anonymization in Health Data

The intricacies of anonymization and de-identification within health data


science present both a labyrinthine challenge and a moral imperative. The
principles of these processes are anchored in the necessity to balance the
utility of data and the privacy of individuals, providing the scaffold for the
ethical use of sensitive health information.

Anonymization involves stripping personal identifiers from health data to


prevent the association of the data with the individuals to whom it pertains.
De-identification, as defined by HIPAA, involves removing specific pieces
of information (known as identifiers) that could be used directly or
indirectly to identify an individual.

De-identification Standards: HIPAA outlines two methods for de-


identification: the Expert Determination Method and the Safe Harbor
Method. The Expert Determination Method requires an expert to apply
statistical or scientific principles to ascertain the risk of re-identification is
exceedingly small. The Safe Harbor Method involves the removal of 18
types of identifiers, such as names, geographic subdivisions smaller than a
state, all elements of dates related to an individual, and other unique
identifying numbers or codes.

Through Python programming, data scientists can automate some aspects of


the de-identification process. The following code demonstrates how one
might remove identifiers from a dataset:

```python
import pandas as pd

# A hypothetical dataframe with patient health data


patient_data = pd.DataFrame({
'Name': ['John Doe', 'Jane Smith'],
'DOB': ['01/01/1990', '02/02/1985'],
'Diagnosis': ['Diabetes', 'Hypertension'],
'SSN': ['123-45-6789', '987-65-4321']
})

# Function to de-identify the data by removing specific identifiers


def deidentify_data(df):
"""
This function removes columns from a dataframe that contain identifiers
as specified by the HIPAA Safe Harbor Method.
"""
columns_to_remove = ['Name', 'DOB', 'SSN']
deidentified_df = df.drop(columns=columns_to_remove)
return deidentified_df

# Apply the deidentification to the patient data


deidentified_patient_data = deidentify_data(patient_data)

print(deidentified_patient_data)
```

b) The Implications of Anonymization: The process of anonymization is


not without its complications. True anonymization requires that re-
identification of the data be impossible, which, given the richness of
health data and advancements in re-identification techniques, is
increasingly difficult to guarantee.

In addition to technical mechanisms for data protection, data scientists must


be cognizant of the ethical landscape. They must weigh the benefits of
research and analysis against the risks implicit in handling re-identifiable
data. This requires a combination of innovative technical solutions, the
application of rigorous standards, and an unwavering commitment to
patient privacy.

The anonymization and de-identification of health data are not merely


technical exercises but are reflective of the esteem with which the field of
health data science holds individual privacy. As you navigate the
complexities of these tasks, remember that each datum detached from its
personal identifier is a step towards preserving the sanctity of personal
health information and a testament to the integrity of the field.

The Moral Compass of Machine Learning in Health Data


Within the rapidly evolving frontier of health data analysis and machine
learning lies a critical axis of ethical considerations. These considerations
are the compass by which the field orients itself, ensuring that the pursuit of
knowledge remains tethered to the core values of beneficence, non-
maleficence, autonomy, and justice.

Machine learning, with its profound potential to uncover insights and


patterns within vast troves of data, brings forth questions of bias, fairness,
and the potential for unintended harm. The datasets we use are mirrors of
the societies they are drawn from, often reflecting historical inequities and
prejudices. A machine learning model is only as unbiased as the data it is
fed, and it is incumbent upon data scientists to rigorously examine and
mitigate these biases.

Ethical Machine Learning: To create models that embody ethical principles,


it is necessary to implement a multi-faceted approach:

- Bias Auditing: Utilizing tools and techniques to detect and measure bias in
datasets and model predictions.
- Fairness Metrics: Applying statistical measures to evaluate and ensure that
models do not disproportionately favor or disadvantage any group.
- Explainability: Developing models that are transparent and interpretable,
allowing stakeholders to understand the rationale behind model predictions.
- Impact Assessment: Considering the consequences of deploying machine
learning models, particularly those that may affect patient care or health
outcomes.

Consider the following Python code that demonstrates a bias audit using a
fairness metric:

```python
from sklearn.metrics import accuracy_score
from aif360.metrics import BinaryLabelDatasetMetric
from aif360.datasets import BinaryLabelDataset
# A hypothetical binary classification model predicts patient health
outcomes
# Actual and predicted outcomes
actual = [1, 1, 0, 0, 1]
predicted = [1, 0, 0, 0, 1]

# Assessing the accuracy of the model


accuracy = accuracy_score(actual, predicted)
print(f"Model Accuracy: {accuracy}")

# Assume 'protected_attribute' is a binary attribute representing a sensitive


feature such as gender
protected_attribute = [0, 1, 0, 1, 0]

# Creating a binary label dataset to apply fairness metrics


binary_dataset =
BinaryLabelDataset(df=pd.DataFrame(protected_attribute), label_names=
['Outcome'], protected_attribute_names=['Gender'])

# Calculating the Disparate Impact metric


metric = BinaryLabelDatasetMetric(binary_dataset, unprivileged_groups=
[{'Gender': 1}], privileged_groups=[{'Gender': 0}])
disparate_impact = metric.disparate_impact()
print(f"Disparate Impact: {disparate_impact:.2f}")

```

The Ethical Framework in Practice: The practice of ethical machine


learning extends beyond the computational and into the world of human
values. It requires a commitment to continuous learning and adaptation as
societal norms evolve and our understanding of fairness deepens.
Thus, as you develop machine learning models and wield the tools of data
analysis, let your practice be guided not just by the pursuit of accuracy and
efficiency, but by a steadfast commitment to ethical principles that uphold
the dignity and rights of all individuals. Your work does not exist in a
vacuum; it has the power to affect health outcomes and, by extension, the
very fabric of human lives.

Navigating the Data Governance Labyrinth

At the heart of health data science lies the labyrinth of data governance—a
complex network of ethical, legal, and procedural considerations that
safeguard the integrity and appropriate use of healthcare data. Consent is
the golden thread that guides the journey through this labyrinth, ensuring
that patients' autonomy and preferences are respected at every turn.

The governance of health data is not merely a regulatory hurdle but a


foundational aspect of patient trust and the ethical use of information. It
involves the structured oversight of data access, quality, and manipulation,
where the principles of transparency, accountability, and stewardship are
paramount.

Data Governance in Python: To illustrate how Python can be used to


manage consent and data governance in healthcare, let us explore a code
snippet that could be part of a larger system for tracking patient consent:

```python
import pandas as pd

# A hypothetical dataset containing patient IDs and consent status


data = {
'Patient_ID': [101, 102, 103, 104, 105],
'Consent_Given': ['Yes', 'No', 'Yes', 'No', 'Yes']
}
consent_df = pd.DataFrame(data)

# Function to check if consent is given for a specific patient


def check_consent(patient_id):
consent_status = consent_df[consent_df['Patient_ID'] == patient_id]
['Consent_Given'].values[0]
if consent_status == 'Yes':
print(f"Consent given for patient ID: {patient_id}")
return True
else:
print(f"Consent not given for patient ID: {patient_id}")
return False

# Example of checking consent for patient 103


check_consent(103)
```

b) The Pillars of Data Governance: As we dive into the intricacies of


consent and governance, we must consider the various pillars that
support robust data management practices:

- Informed Consent: Acquiring explicit permission from patients, ensuring


they understand how their data will be used, and respecting their choice to
opt-in or out.
- Data Stewardship: Assigning roles and responsibilities to individuals or
groups who manage the data's lifecycle, ensuring it is kept accurate, secure,
and used in accordance with agreed-upon policies.
- Compliance: Adhering to relevant laws, such as HIPAA and GDPR, which
dictate standards for data protection, patient rights, and breach protocols.
- Ethical Review: Subjecting data usage and research projects to scrutiny by
ethics committees or Institutional Review Boards (IRBs) to evaluate the
potential impact on patient welfare and privacy.
Practitioners in the field must be vigilant guardians of data governance,
wielding their Python skills as instruments of integrity and trust. This
section has not only highlighted the essentiality of consent and governance
in healthcare data but also provided tangible examples of how Python can
be utilized to navigate these critical aspects. The code and concepts
presented herein serve as building blocks for creating systems that honor
patient autonomy and contribute to the ethical advancement of health data
science.
CHAPTER 2:
INTERMEDIATE DATA
MANIPULATION AND
ANALYSIS

I
n the digital expanse of healthcare data, the ability to manipulate and
extract value from complex datasets is not just an asset—it is a necessity.
Advanced Pandas techniques provide the toolkit for health data
scientists to transform raw data into actionable insights. This section
introduces sophisticated methods that leverage Pandas, the cornerstone of
data manipulation in Python, guiding you through nuanced approaches that
cater to the specificity of healthcare data.

Advanced indexing methods including MultiIndex for hierarchical data


structures and boolean indexing for subsetting datasets based on
conditionals are pivotal in navigating health datasets that often come with
multiple dimensions of categorical and time-series information. For
example:

```python
import pandas as pd

# Sample DataFrame creation with MultiIndex


arrays = [pd.array(['cardiology', 'oncology', 'oncology', 'cardiology']),
pd.array(['blood test', 'tumor marker', 'biopsy', 'ECG'])]
tuples = list(zip(*arrays))
index = pd.MultiIndex.from_tuples(tuples, names=["Department", "Test"])
data = pd.DataFrame({"Result": [89, 120, 45, 60]}, index=index)

# Accessing a cross-section of the data for 'oncology'


oncology_data = data.loc['oncology']
print(oncology_data)
```

Techniques for Complex Healthcare Scenarios: The reality of healthcare


data is that it often presents scenarios requiring more than simple
transformations. Time-series analysis is critical when dealing with patient
health records where trends over time can unveil patterns crucial for
diagnosis or treatment plans. In the same vein, methods of advanced data
aggregation and summarization, such as pivot tables and groupby
operations, allow for a multifaceted view of the data, isolating key metrics
that inform patient care or operational efficiency.

When it comes to the often-unavoidable reality of missing data within


clinical datasets, Pandas provides robust methods for interpolation and
imputation that maintain the integrity of the dataset while allowing for
comprehensive analysis.

Merging and joining multiple sources of health data can be a significant


challenge due to the varied nature of data formats and standards in the
medical field. Pandas' merging and concatenation functions are vital for
creating a coherent dataset that health professionals can draw reliable
conclusions from.

Let us take a deeper look into these techniques with a focus on how they
can be applied to handle healthcare-specific data challenges:

Merging Data from Different Sources: In healthcare, data may come from
electronic health records (EHRs), laboratory results, and patient surveys,
each with its own structure. The ability to merge these sources into a single,
analyzable dataset is essential. For instance, consider two datasets: one
containing patient demographics and the other containing laboratory test
results. We can merge these two datasets using a common key, such as
patient ID, to form a single DataFrame:

```python
# Assume we have two DataFrames: patient_demo_df and lab_results_df,
both having 'PatientID' as a common key.
combined_data = pd.merge(patient_demo_df, lab_results_df,
on='PatientID', how='inner')

# Display the merged DataFrame


print(combined_data.head())
```

Through these advanced Pandas techniques, health data scientists can


ensure that their analyses are not just comprehensive, but also nuanced and
specific to the exigencies of the healthcare domain.

Mastery of Multi-Dimensional Data

Consider a dataset that spans various departments, each running multiple


tests, over several time periods. To manage this complexity, a MultiIndex
can be established, creating a tiered structure that allows for precise
selection and slicing of the data:

```python
# Import Pandas library
import pandas as pd

# Creating a sample multi-dimensional DataFrame with time series data


time_index = pd.date_range('2023-01-01', periods=4, freq='Q')
Another random document with
no related content on Scribd:
THE INLET OF PEACH BLOSSOMS
[From “Dashes at Life with a Free Pencil,” 1845. The story
was first published between 1840 and 1845, probably in the
“New Mirror” of New York.]

THE Emperor Yuentsoong, of the dynasty Chow, was the most


magnificent of the long-descended succession of Chinese
sovereigns. On his first accession to the throne, his character was so
little understood, that a conspiracy was set on foot among the
yellow-caps, or eunuchs, to put out his eyes, and place upon the
throne the rebel Szema, in whose warlike hands, they asserted, the
empire would more properly maintain its ancient glory. The gravity
and reserve which these myrmidons of the palace had construed into
stupidity and fear, soon assumed another complexion, however. The
eunuchs silently disappeared; the mandarins and princes whom they
had seduced from their allegiance were made loyal subjects by a
generous pardon; and, in a few days after the period fixed upon for
the consummation of the plot, Yuentsoong set forth in complete
armor at the head of his troops to give battle to the rebel in the
mountains.
In Chinese annals this first enterprise of the youthful Yuentsoong
is recorded with great pomp and particularity. Szema was a Tartar
prince of uncommon ability, young, like the emperor, and, during the
few last imbecile years of the old sovereign, he had gathered
strength in his rebellion, till now he was at the head of ninety
thousand men, all soldiers of repute and tried valor. The historian
has, unfortunately, dimmed the emperor’s fame to European eyes by
attributing his wonderful achievements in this expedition to his
superiority in arts of magic. As this account of his exploits is only
prefatory to our tale, we will simply give the reader an idea of the
style of the historian by translating literally a passage or two of his
description of the battle:—
“Szema now took refuge within a cleft of the mountain, and
Yuentsoong, upon his swift steed, outstripping the body-guard in his
ardor, dashed amid the paralyzed troops with poised spear, his eyes
fixed only on the rebel. There was a silence of an instant, broken
only by the rattling hoofs of the intruder; and then, with dishevelled
hair and waving sword, Szema uttered a fearful imprecation. In a
moment the wind rushed, the air blackened, and, with the
suddenness of a fallen rock, a large cloud enveloped the rebel, and
innumerable men and horses issued out of it. Wings flapped against
the eyes of the emperor’s horse, hellish noises screamed in his ears,
and, completely beyond control, the animal turned and fled back
through the narrow pass, bearing his imperial master safe into the
heart of his army.
“Yuentsoong, that night, commanded some of his most expert
soldiers to scale the beetling heights of the ravine, bearing upon their
backs the blood of swine, sheep, and dogs, with other impure things,
and these they were ordered to shower upon the combatants at the
sound of the imperial clarion. On the following morning, Szema came
forth again to offer battle, with flags displayed, drums beating, and
shouts of triumph and defiance. As on the day previous, the bold
emperor divided, in his impatience, rank after rank of his own
soldiery, and, followed closely by his body-guard, drove the rebel
army once more into their fastness. Szema sat upon his war-horse
as before, intrenched amid his officers and ranks of the tallest Tartar
spearmen; and, as the emperor contended hand to hand with one of
the opposing rebels, the magic imprecation was again uttered, the
air again filled with cloudy horsemen and chariots, and the mountain
shaken with discordant thunder. Backing his willing steed, the
emperor blew a long sharp note upon his silver clarion, and, in an
instant, the sun broke through the darkness, and the air seemed
filled with paper men, horses of straw, and phantoms dissolving into
smoke. Yuentsoong and Szema now stood face to face, with only
mortal aid and weapons.”
The historian goes on to record that the two armies suspended
hostilities at the command of their leaders, and that, the emperor and
his rebel subject having engaged in single combat, Yuentsoong was
victorious, and returned to his capital with the formidable enemy
whose life he had spared, riding beside him like a brother. The
conqueror’s career, for several years after this, seems to have been
a series of exploits of personal valor; and the Tartar prince shared in
all his dangers and pleasures, his inseparable friend. It was during
this period of romantic friendship that the events occurred which
have made Yuentsoong one of the idols of Chinese poetry.
By the side of a lake in a distant province of the empire, stood
one of the imperial palaces of pleasure, seldom visited, and almost
in ruins. Hither, in one of his moody periods of repose from war,
came the conqueror Yuentsoong, for the first time in years separated
from his faithful Szema. In disguise, and with only one or two
attendants, he established himself in the long silent halls of his
ancestor Tsinchemong, and with his boat upon the lake, and his
spear in the forest, seemed to find all the amusement of which his
melancholy was susceptible. On a certain day in the latter part of
April, the emperor had set his sail to a fragrant south wind, and,
reclining on the cushions of his bark, watched the shore as it softly
and silently glided past, and, the lake being entirely encircled by the
imperial forest, he felt immersed in what he believed to be the
solitude of a deserted paradise. After skirting the fringed sheet of
water in this manner for several hours, he suddenly observed that he
had shot through a streak of peach-blossoms floating from the shore,
and at the same moment he became conscious that his boat was
slightly headed off by a current setting outward. Putting up his helm,
he returned to the spot, and beneath the drooping branches of some
luxuriant willows, thus early in leaf, he discovered the mouth of an
inlet, which, but for the floating blossoms it brought to the lake, would
have escaped the notice of the closest observer. The emperor now
lowered his sail, unshipped the slender mast, and betook him to the
oars; and, as the current was gentle, and the inlet wider within the
mouth, he sped rapidly on through what appeared to be but a lovely
and luxuriant vale of the forest. Still, those blushing betrayers of
some flowering spot beyond extended like a rosy clew before him;
and with impulse of muscles swelled and indurated in warlike
exercise, the swift keel divided the besprent mirror winding
temptingly onward, and, for a long hour, the royal oarsman untiringly
threaded this sweet vein of the wilderness.
Resting a moment on his oars while the slender bark still kept
her way, he turned his head toward what seemed to be an opening
in the forest on the left, and in the same instant the boat ran head
on, to the shore, the inlet at this point almost doubling on its course.
Beyond, by the humming of bees and the singing of birds, there
should be a spot more open than the tangled wilderness he had
passed; and, disengaging his prow from the alders, he shoved the
boat again into the stream, and pulled round a high rock, by which
the inlet seemed to have been compelled to curve its channel. The
edge of a bright green meadow now stole into the perspective, and,
still widening with his approach, disclosed a slightly rising terrace
clustered with shrubs, and studded here and there with vases; and
farther on, upon the same side of the stream, a skirting edge of
peach-trees loaded with the gay blossoms which had guided him
thither.
Astonished at these signs of habitation in what was well
understood to be a privileged wilderness, Yuentsoong kept his boat
in mid-stream, and with his eyes vigilantly on the alert, slowly made
headway against the current. A few strokes with his oars, however,
traced another curve of the inlet, and brought into view a grove of
ancient trees scattered over a gently ascending lawn, beyond which,
hidden from the river till now by the projecting shoulder of a mound,
lay a small pavilion with gilded pillars glittering like fairy work in the
sun. The emperor fastened his boat to a tree leaning over the water,
and with his short spear in his hand, bounded upon the shore, and
took his way toward the shining structure, his heart beating with a
feeling of wonder and interest altogether new. On a nearer approach,
the bases of the pillars seemed decayed by time, and the gilding
weather-stained and tarnished; but the trellised porticoes on the
southern aspect were laden with flowering shrubs in vases of
porcelain, and caged birds sang between the pointed arches, and
there were manifest signs of luxurious taste, elegance, and care.
A moment with an indefinable timidity the emperor paused
before stepping from the greensward upon the marble floor of the
pavilion, and in that moment a curtain was withdrawn from the door,
and a female, with step suddenly arrested by the sight of the
stranger, stood motionless before him. Ravished with her
extraordinary beauty, and awe-struck with the suddenness of the
apparition and the novelty of the adventure, the emperor’s tongue
cleaved to his mouth, and ere he could summon resolution, even for
a gesture of courtesy, the fair creature had fled within, and the
curtain closed the entrance as before.
Wishing to recover his composure, so strangely troubled, and
taking it for granted that some other inmate of the house would soon
appear, Yuentsoong turned his steps aside to the grove; and with his
head bowed, and his spear in the hollow of his arm, tried to recall
more vividly the features of the vision he had seen. He had walked
but a few paces when there came toward him from the upper skirt of
the grove, a man of unusual stature and erectness, with white hair
unbraided on his shoulders, and every sign of age except infirmity of
step and mien. The emperor’s habitual dignity had now rallied, and
on his first salutation the countenance of the old man softened, and
he quickened his pace to meet and give him welcome.
“You are noble?” he said with confident inquiry.
Yuentsoong colored slightly.
“I am,” he replied, “Lew-melin, a prince of the empire.”
“And by what accident here?”
Yuentsoong explained the clew of the peach-blossoms, and
represented himself as exiled for a time to the deserted palace upon
the lakes.
“I have a daughter,” said the old man abruptly, “who has never
looked on human face save mine.”
“Pardon me,” replied his visitor, “I have thoughtlessly intruded on
her sight, and a face more heavenly fair”—
The emperor hesitated, but the old man smiled encouragingly.
“It is time,” he said, “that I should provide a younger defender for
my bright Teh-leen, and Heaven has sent you in the season of
42
peach-blossoms with provident kindness. You have frankly
revealed to me your name and rank. Before I offer you the hospitality
of my roof, I must tell you mine. I am Choo-tseen, the outlaw, once of
your own rank, and the general of the Celestial army.”
The emperor started, remembering that this celebrated rebel
was the terror of his father’s throne.
“You have heard my history,” the old man continued. “I had been,
before my rebellion, in charge of the imperial palace on the lake.
Anticipating an evil day, I secretly prepared this retreat for my family;
and when my soldiers deserted me at the battle of Ke-chow, and a
price was set upon my head, hither I fled with my women and
children; and the last alive is my beautiful Teh-leen. With this brief
outline of my life, you are at liberty to leave me as you came, or to
enter my house on the condition that you become the protector of my
child.”
The emperor eagerly turned toward the pavilion, and, with a step
as light as his own, the erect and stately outlaw hastened to lift the
curtain before him. Leaving his guest for a moment in the outer
apartment, he entered to an inner chamber in search of his daughter,
whom he brought, panting with fear, and blushing with surprise and
delight, to her future lover and protector. A portion of an historical
tale so delicate as the description of the heroine is not work for
imitators, however, and we must copy strictly the portrait of the
matchless Teh-leen, as drawn by Le-pih, the Anacreon of Chinese
poetry and the contemporary and favorite of Yuentsoong.
“Teh-leen was born while the morning star shone upon the
bosom of her mother. Her eye was like the unblemished blue lily, and
its light like the white gem unfractured. The plum-blossom is most
fragrant when the cold has penetrated its stem, and the mother of
Teh-leen had known sorrow. The head of her child drooped in
thought, like a violet overladen with dew. Bewildering was Teh-leen.
Her mouth’s corners were dimpled, yet pensive. The arch of her
brows was like the vein in the tulip’s heart, and the lashes shaded
the blushes on her cheek. With the delicacy of a pale rose, her
complexion put to shame the floating light of day. Her waist, like a
thread in fineness, seemed ready to break, yet was it straight and
erect, and feared not the fanning breeze; and her shadowy grace
was as difficult to delineate as the form of the white bird rising from
the ground by moonlight. The natural gloss of her hair resembled the
uncertain sheen of calm water, yet without the false aid of unguents.
The native intelligence of her mind seemed to have gained strength
by retirement; and he who beheld her thought not of her as human.
Of rare beauty, of rarer intellect, was Teh-leen, and her heart
responded to the poet’s lute.”
We have not space, nor could we, without copying directly from
the admired Le-pih, venture to describe the bringing of Teh-leen to
court, and her surprise at finding herself the favorite of the emperor.
It is a romantic circumstance, besides, which has had its parallels in
other countries. But the sad sequel to the loves of poor Teh-leen is
but recorded in the cold page of history; and if the poet, who wound
up the climax of her perfections with her susceptibility to his lute,
embalmed her sorrows in verse, he was probably too politic to bring
it ever to light. Pass we to these neglected and unadorned passages
of her history.
Yuentsoong’s nature was passionately devoted and confiding;
and, like two brothers with one favorite sister, lived together Teh-
leen, Szema, and the emperor. The Tartar prince, if his heart knew a
mistress before the arrival of Teh-leen at the palace, owned
afterward no other than her; and, fearless of check or suspicion from
the noble confidence and generous friendship of Yuentsoong, he
seemed to live but for her service, and to have neither energies nor
ambition except for the winning of her smiles. Szema was of great
personal beauty, frank when it did not serve him to be wily, bold in
his pleasures, and of manners almost femininely soft and
voluptuous. He was renowned as a soldier, and, for Teh-leen, he
became a poet and master of the lute; and, like all men formed for
ensnaring the heart of women, he seemed to forget himself in the
absorbing devotion of his idolatry. His friend the emperor was of
another mould. Yuentsoong’s heart had three chambers,—love,
friendship, and glory. Teh-leen was but a third in his existence, yet he
loved her,—the sequel will show how well. In person, he was less
beautiful than majestic, of large stature, and with a brow and lip
naturally stern and lofty. He seldom smiled, even upon Teh-leen,
whom he would watch for hours in pensive and absorbed delight; but
his smile, when it did awake, broke over his sad countenance like
morning. All men loved and honored Yuentsoong; and all men,
except only the emperor, looked on Szema with antipathy. To such
natures as the former, women give all honor and approbation; but,
for such as the latter, they reserve their weakness!
Wrapt up in his friend and mistress, and reserved in his
intercourse with his counsellors, Yuentsoong knew not that,
throughout the imperial city, Szema was called “the kieu,” or robber-
bird, and his fair Teh-leen openly charged with dishonor. Going out
alone to hunt, as was his custom, and having left his signet with
Szema, to pass and repass through the private apartments at his
pleasure, his horse fell with him unaccountably in the open field.
Somewhat superstitious, and remembering that good spirits
sometimes “knit the grass” when other obstacles fail to bar our way
into danger, the emperor drew rein, and returned to his palace. It
was an hour after noon, and, having dismissed his attendants at the
city gate, he entered by a postern to the imperial garden, and
bethought himself of the concealed couch in a cool grot by a fountain
(a favorite retreat, sacred to himself and Teh-leen), where he fancied
it would be refreshing to sleep away the sultriness of the remaining
hours till evening. Sitting down by the side of the murmuring fount,
he bathed his feet, and left his slippers on the lip of the basin to be
unencumbered in his repose within, and so, with unechoing step,
entered the resounding grotto. Alas! there slumbered the faithless
friend with the guilty Teh-leen upon his bosom!
Grief struck through the noble heart of the emperor like a sword
in cold blood. With a word he could consign to torture and death the
robber of his honor, but there was agony in his bosom deeper than
revenge. He turned silently away, recalling his horse and huntsmen,
and, outstripping all, plunged on through the forest till night gathered
around him.
Yuentsoong had been absent many days from his capital, and
his subjects were murmuring their fears for his safety, when a
messenger arrived to the counsellors informing them of the
appointment of the captive Tartar prince to the government of the
province of Szechuen, the second honor of the Celestial empire. A
private order accompanied the announcement, commanding the
immediate departure of Szema for the scene of his new authority.
Inexplicable as was this riddle to the multitude, there were those who
read it truly by their knowledge of the magnanimous soul of the
emperor; and among these was the crafty object of his generosity.
Losing no time, he set forward with great pomp for Szechuen, and in
their joy to see him no more in the palace, the slighted princes of the
empire forgave his unmerited advancement. Yuentsoong returned to
his capital; but to the terror of his counsellors and people, his hair
was blanched white as the head of an old man! He was pale as well,
but he was cheerful and kind beyond his wont, and to Teh-leen
untiring in pensive and humble attentions. He pleaded only impaired
health and restless slumbers as an apology for nights of solitude.
Once Teh-leen penetrated to his lonely chamber, but by the dim night
43
lamp she saw that the scroll over the window was changed, and
instead of the stimulus to glory which formerly hung in golden letters
before his eyes, there was a sentence written tremblingly in black:—

“The close wing of love covers the death-throb of honor.”

Six months from this period the capital was thrown into a tumult
with the intelligence that the province of Szechuen was in rebellion,
and Szema at the head of a numerous army on his way to seize the
throne of Yuentsoong. This last sting betrayed the serpent even to
the forgiving emperor, and tearing the reptile at last from his heart,
he entered with the spirit of other times into the warlike preparations.
The imperial army was in a few days on its march, and at Keo-yang
the opposing forces met and prepared for encounter.
With a dread of the popular feeling toward Teh-leen, Yuentsoong
had commanded for her a close litter, and she was borne after the
imperial standard in the centre of the army. On the eve before the
battle, ere the watch-fires were lit, the emperor came to her tent, set
apart from his own, and with the delicate care and kind gentleness
from which he never varied, inquired how her wants were supplied,
and bade her thus early farewell for the night; his own custom of
passing among his soldiers on the evening previous to an
engagement, promising to interfere with what was usually his last
duty before retiring to his couch. Teh-leen on this occasion seemed
moved by some irrepressible emotion, and as he rose to depart, she
fell forward upon her face, and bathed his feet with her tears.
Attributing it to one of those excesses of feeling to which all, but
especially hearts ill at ease, are liable, the noble monarch gently
raised her, and with repeated efforts at re-assurance, committed her
to the hands of her women. His own heart beat far from tranquilly,
for, in the excess of his pity for her grief he had unguardedly called
her by one of the sweet names of their early days of love,—strange
word now upon his lip,—and it brought back, spite of memory and
truth, happiness that would not be forgotten!
It was past midnight, and the moon was riding high in heaven,
when the emperor, returning between the lengthening watch-fires,
sought the small lamp which, suspended like a star above his own
tent, guided him back from the irregular mazes of the camp. Paled
by the intense radiance of the moonlight, the small globe of alabaster
at length became apparent to his weary eye, and with one glance at
the peaceful beauty of the heavens, he parted the curtained door
beneath it, and stood within. The Chinese historian asserts that a
bird, from whose wing Teh-leen had once plucked an arrow, restoring
it to liberty and life, in grateful attachment to her destiny, removed
the lamp from the imperial tent, and suspended it over hers. The
emperor stood beside her couch. Startled at his inadvertent error, he
turned to retire; but the lifted curtain let in a flood of moonlight upon
the sleeping features of Teh-leen, and like dewdrops the undried
tears glistened in her silken lashes. A lamp burned faintly in the inner
apartment of the tent, and her attendants slept soundly. His soft
heart gave way. Taking up the lamp, he held it over his beautiful
mistress, and once more gazed passionately and unrestrainedly on
her unparalleled beauty. The past—the early past—was alone before
him. He forgave her,—there, as she slept, unconscious of the
throbbing of his injured but noble heart so close beside her,—he
forgave her in the long silent abysses of his soul! Unwilling to wake
her from her tranquil slumber, but promising to himself, from that
hour, such sweets of confiding love as had well-nigh been lost to him
forever, he imprinted one kiss upon the parted lips of Teh-leen, and
sought his couch for slumber.
Ere daybreak the emperor was aroused by one of his attendants
with news too important for delay. Szema, the rebel, had been
arrested in the imperial camp, disguised, and on his way back to his
own forces; and like wildfire the information had spread among the
soldiery, who, in a state of mutinous excitement, were with difficulty
restrained from rushing upon the tent of Teh-leen. At the door of his
tent, Yuentsoong found messengers from the alarmed princes and
officers of the different commands, imploring immediate aid and the
imperial presence to allay the excitement; and while the emperor
prepared to mount his horse, the guard arrived with the Tartar prince,
ignominiously tied, and bearing marks of rough usage from his
indignant captors.
“Loose him!” cried the emperor, in a voice of thunder.
The cords were severed, and with a glance whose ferocity
expressed no thanks, Szema reared himself up to his fullest height,
and looked scornfully around him. Daylight had now broke, and as
the group stood upon an eminence in sight of the whole army, shouts
began to ascend, and the armed multitude, breaking through all
restraint, rolled in toward the centre. Attracted by the commotion,
Yuentsoong turned to give some orders to those near him, when
Szema suddenly sprang upon an officer of the guard, wrenched his
drawn sword from his grasp, and in an instant was lost to sight in the
tent of Teh-leen. A sharp scream, a second of thought, and forth
again rushed the desperate murderer, with his sword flinging drops
of blood, and ere a foot stirred in the paralyzed group, the avenging
cimeter of Yuentsoong had cleft him to the chin.
A hush, as if the whole army was struck dumb by a bolt from
heaven, followed this rapid tragedy. Dropping the polluted sword
from his hand, the emperor, with uncertain step, and the pallor of
death upon his countenance, entered the fatal tent.
He came no more forth that day. The army was marshalled by
the princes, and the rebels were routed with great slaughter; but
Yuentsoong never more wielded sword. “He pined to death,” says
the historian, “with the wane of the same moon that shone upon the
forgiveness of Teh-leen.”
CAROLINE MATILDA STANSBURY
KIRKLAND
1801–1864

Mrs. Kirkland was recognised as one of the New York literary set during the
flourishing of Willis. Her marriage to Professor William Kirkland (1827) took her to
Central New York, and in 1839 to Michigan frontier. The emigration produced
immediately A New Home—Who’ll Follow (New York, 1839). “Miss Mitford’s
charming sketches of village life,” she says in her preface, “suggested the form.” It
is the best of her books, not only in its distinct historical value as a document of
frontier life, but also in its vivacity and keen intelligence of style. Of structure there
is very little, a mere series of descriptions, with an occasional sketch in narrative.
Returning to New York in 1842, she opened a school for girls, wrote for the
magazines, and published, as a sequel to her first book, Forest Life (New York and
Boston, 1842). Her tales, collected under the title Western Clearings (New York,
1846), show the same qualities as her descriptions—racy dialect, dashes of
penetrative characterisation, quick suggestion of manners; but their narrative
consistency is not usually strong enough to hold interest. She returned to her first
form in Holidays Abroad (1849). After that the titles of her books suggest hack-
work. Meantime Mr. Kirkland had won his place as an editor. Poe included them
both, the husband perfunctorily, the wife cordially, among his Literati.
THE BEE-TREE
[From “Western Clearings” 1846, a collection composed both
of contributions to magazines and annuals and of new matter. The
reprint below omits an explanatory introduction and an episodic
love-story which, besides being feeble, is rendered quite
superfluous by the dénouement.]

IT was on one of the lovely mornings of our ever lovely autumn, so


early that the sun had scarcely touched the tops of the still verdant
forest, that Silas Ashburn and his eldest son sallied forth for a day’s
chopping on the newly-purchased land of a rich settler, who had been
but a few months among us. The tall form of the father, lean and gaunt
as the very image of Famine, derived little grace from the rags which
streamed from the elbows of his almost sleeveless coat, or flapped
round the tops of his heavy boots, as he strode across the long
causeway that formed the communication from his house to the dry
land. Poor Joe’s costume showed, if possible, a still greater need of
the aid of that useful implement, the needle. His mother is one who
thinks little of the ancient proverb that commends the stitch in time;
and the clothing under her care sometimes falls in pieces, seam by
seam. For want of this occasional aid is rendered more especially
necessary by the slightness of the original sewing; so that the brisk
breeze of the morning gave the poor boy no faint resemblance to a tall
young aspen,

“With all its leaves fast fluttering, all at once.”

The little conversation which passed between the father and son
was such as necessarily makes up much of the talk of the poor.
“If we hadn’t had sich bad luck this summer,” said Mr. Ashburn,
“losing that heifer, and the pony, and them three hogs,—all in that
plaguy spring-hole, too,—I thought to have bought that timbered forty
of Dean. It would have squared out my farm jist about right.”
“The pony didn’t die in the spring-hole, father,” said Joe.
“No, he did not, but he got his death there, for all. He never
stopped shiverin’ from the time he fell in. You thought he had the agur,
but I know’d well enough what ailded him; but I wasn’t agoin’ to let
Dean know, because he’d ha’ thought himself so blam’d cunning, after
all he’d said to me about that spring-hole. If the agur could kill, Joe,
we’d all ha’ been dead long ago.”
Joe sighed,—a sigh of assent. They walked on musingly.
“This is going to be a good job of Keene’s,” continued Mr. Ashburn,
turning to a brighter theme, as they crossed the road and struck into
the “timbered land,” on their way to the scene of the day’s operations.
“He has bought three eighties, all lying close together, and he’ll want
as much as one forty cleared right off; and I’ve a good notion to take
the fencin’ of it as well as the choppin’. He’s got plenty of money, and
they say he don’t shave quite so close as some. But I tell you, Joe, if I
do take the job, you must turn to like a catamount, for I ain’t a-going to
make a nigger o’ myself, and let my children do nothing but eat.”
“Well, father,” responded Joe, whose pale face gave token of any
thing but high living, “I’ll do what I can; but you know I never work two
days at choppin’ but what I have the agur like sixty,—and a feller can’t
work when he’s got the agur.”
“Not while the fit’s on, to be sure,” said the father, “but I’ve worked
many an afternoon after my fit was over, when my head felt as big as a
half-bushel, and my hands would ha’ sizzed if I had put ’em in water.
Poor folks has got to work—but Joe! if there isn’t bees, by golley! I
wonder if anybody’s been a baitin’ for ’em? Stop! hush! watch which
way they go!”
And with breathless interest—forgetful of all troubles, past,
present, and future—they paused to observe the capricious wheelings
and flittings of the little cluster, as they tried every flower on which the
sun shone, or returned again and again to such as suited best their
discriminating taste. At length, after a weary while, one suddenly rose
into the air with a loud whizz, and after balancing a moment on a level
with the tree-tops, darted off, like a well-sent arrow, toward the east,
followed instantly by the whole busy company, till not a loiterer
remained.
“Well! if this isn’t luck!” exclaimed Ashburn, exultingly; “they make
right for Keene’s land! We’ll have ’em! go ahead, Joe, and keep your
eye on ’em!”
Joe obeyed so well in both points that he not only outran his father,
but very soon turned a summerset over a gnarled root or grub which
lay in his path. This faux pas nearly demolished one side of his face,
and what remained of his jacket sleeve, while his father, not quite so
heedless, escaped falling, but tore his boot almost off with what he
called “a contwisted stub of the toe.”
But these were trifling inconveniences, and only taught them to use
a little more caution in their eagerness. They followed on, unweariedly;
crossed several fences, and threaded much of Mr. Keene’s tract of
forest-land, scanning with practised eye every decayed tree, whether
standing or prostrate, until at length, in the side of a gigantic but
leafless oak, they espied, some forty feet from the ground, the “sweet
home” of the immense swarm whose scouts had betrayed their hiding-
place.
“The Indians have been here;” said Ashburn; “you see they’ve
felled this saplin’ agin the bee-tree, so as they could climb up to the
hole; but the red devils have been disturbed afore they had time to dig
it out. If they’d had axes to cut down the big tree, they wouldn’t have
left a smitchin o’ honey, they’re such tarnal thieves!”
Mr. Ashburn’s ideas of morality were much shocked at the thought
of the dishonesty of the Indians, who, as is well known, have no rights
of any kind; but considering himself as first finder, the lawful proprietor
of this much-coveted treasure, gained too without the trouble of a
protracted search, or the usual amount of baiting, and burning of
honeycombs, he lost no time in taking possession after the established
mode.
To cut his initials with his axe on the trunk of the bee-tree, and to
make blazes on several of the trees he had passed, detained him but a
few minutes; and with many a cautious noting of the surrounding
localities, and many a charge to Joe “not to say nothing to nobody,”
Silas turned his steps homeward, musing on the important fact that he
had had good luck for once, and planning important business quite
foreign to the day’s chopping.
Now it so happened that Mr. Keene, who is a restless old
gentleman, and, moreover, quite green in the dignity of a land-holder,
thought proper to turn his horse’s head, for this particular morning ride,
directly towards these same “three eighties,” on which he had engaged
Ashburn and his son to commence the important work of clearing. Mr.
Keene is low of stature, rather globular in contour, and exceedingly
parrot-nosed; wearing, moreover, a face red enough to lead one to
suppose he had made his money as a dealer in claret; but, in truth,
one of the kindest of men, in spite of a little quickness of temper. He is
profoundly versed in the art and mystery of store-keeping, and as
profoundly ignorant of all that must sooner or later be learned by every
resident land-owner of the western country.
Thus much being premised, we shall hardly wonder that our good
old friend felt exceedingly aggrieved at meeting Silas Ashburn and the
“lang-legged chiel” Joe, (who has grown longer with every shake of
ague,) on the way from his tract, instead of to it.
“What in the world’s the matter now!” began Mr. Keene, rather
testily. “Are you never going to begin that work?”
“I don’t know but I shall;” was the cool reply of Ashburn; “I can’t
begin it to-day, though.”
“And why not, pray, when I’ve been so long waiting?”
“Because, I’ve got something else that must be done first. You
don’t think your work is all the work there is in the world, do you?”
Mr. Keene was almost too angry to reply, but he made an effort to
say, “When am I to expect you, then?”
“Why, I guess we’ll come on in a day or two, and then I’ll bring both
the boys.”
So saying, and not dreaming of having been guilty of an incivility,
Mr. Ashburn passed on, intent only on his bee-tree.
Mr. Keene could not help looking after the ragged pair for a
moment, and he muttered angrily as he turned away, “Aye! pride and
beggary go together in this confounded new country! You feel very
independent, no doubt, but I’ll try if I can’t find somebody that wants
money.”
And Mr. Keene’s pony, as if sympathizing with his master’s
vexation, started off at a sharp, passionate trot, which he has learned,
no doubt, under the habitual influence of the spicy temper of his rider.
To find labourers who wanted money, or who would own that they
wanted it, was at that time no easy task. Our poorer neighbours have
been so little accustomed to value household comforts, that the
opportunity to obtain them presents but feeble incitement to continuous
industry. However, it happened in this case that Mr. Keene’s star was
in the ascendant, and the woods resounded, ere long, under the sturdy
strokes of several choppers.

* * * * *
The Ashburns, in the mean time, set themselves busily at work to
make due preparations for the expedition which they had planned for
the following night. They felt, as does every one who finds a bee-tree
in this region, that the prize was their own—that nobody else had the
slightest claim to its rich stores; yet the gathering in of the spoils was to
be performed, according to the invariable custom where the country is
much settled, in the silence of night, and with every precaution of
secrecy. This seems inconsistent, yet such is the fact.
The remainder of the “lucky” day and the whole of the succeeding
one passed in scooping troughs for the reception of the honey,—
tedious work at best, but unusually so in this instance, because several
of the family were prostrate with the ague. Ashburn’s anxiety lest some
of his customary bad luck should intervene between discovery and
possession, made him more impatient and harsh than usual; and the
interior of that comfortless cabin would have presented to a chance
visitor, who knew not of the golden hopes which cheered its inmates,
an aspect of unmitigated wretchedness. Mrs. Ashburn sat almost in the
fire, with a tattered hood on her head and the relics of a bed-quilt
wrapped about her person; while the emaciated limbs of the baby on
her lap,—two years old, yet unweaned,—seemed almost to reach the
floor, so preternaturally were they lengthened by the stretches of a four
months’ ague. Two of the boys lay in the trundle-bed, which was drawn
as near to the fire as possible; and every spare article of clothing that
the house afforded was thrown over them, in the vain attempt to warm
their shivering frames. “Stop your whimperin’, can’t ye!” said Ashburn,
as he hewed away with hatchet and jack-knife, “you’ll be hot enough
before long.” And when the fever came his words were more than
verified.
Two nights had passed before the preparations were completed.
Ashburn and such of his boys as could work had laboured
indefatigably at the troughs; and Mrs. Ashburn had thrown away the
milk, and the few other stores which cumbered her small supply of
household utensils, to free as many as possible for the grand
occasion. This third day had been “well day” to most of the invalids,
and after the moon had risen to light them through the dense wood,
the family set off, in high spirits, on their long, dewy walk. They had
passed the causeway and were turning from the highway into the skirts
of the forest, when they were accosted by a stranger, a young man in a
hunter’s dress, evidently a traveller, and one who knew nothing of the
place or its inhabitants, as Mr. Ashburn ascertained, to his entire
satisfaction, by the usual number of queries. The stranger, a
handsome youth of one or two and twenty, had that frank, joyous air
which takes so well with us Wolverines; and after he had fully satisfied
our bee-hunter’s curiosity, he seemed disposed to ask some questions
in his turn. One of the first of these related to the moving cause of the
procession and their voluminous display of containers.
“Why, we’re goin’ straight to a bee-tree that I lit upon two or three
days ago, and if you’ve a mind to, you may go ’long, and welcome. It’s
a real peeler, I tell ye! There’s a hundred and fifty weight of honey in it,
if there’s a pound.”
The young traveller waited no second invitation. His light knapsack
being but small incumbrance, he took upon himself the weight of
several troughs that seemed too heavy for the weaker members of the
expedition. They walked on at a rapid and steady pace for a good half
hour, over paths that were none of the smoothest, and only here and
there lighted by the moonbeams. The mother and children were but ill
fitted for the exertion, but Aladdin, on his midnight way to the wondrous
vault of treasure, would as soon have thought of complaining of
fatigue.
Who then shall describe the astonishment, the almost breathless
rage of Silas Ashburn,—the bitter disappointment of the rest,—when
they found, instead of the bee-tree, a great gap in the dense forest,
and the bright moon shining on the shattered fragments of the
immense oak that had contained their prize? The poor children,
fainting with toil now that the stimulus was gone, threw themselves on
the ground; and Mrs. Ashburn, seating her wasted form on a huge
branch, burst into tears.
“It’s all one!” exclaimed Ashburn, when at length he could find
words; “it’s all alike! this is just my luck! It ain’t none of my neighbour’s
work, though! They know better than to be so mean! It’s the rich! Them
that begrudges the poor man the breath of life!” And he cursed bitterly
and with clenched teeth, whoever had robbed him of his right.
“Don’t cry, Betsey,” he continued; “let’s go home. I’ll find out who
has done this, and I’ll let ’em know there’s law for the poor man as well
as the rich. Come along, young ’uns, and stop your blubberin’, and let
them splinters alone!” The poor little things were trying to gather up
some of the fragments to which the honey still adhered, but their father
was too angry to be kind.
“Was the tree on your own land?” now inquired the young stranger,
who had stood by in sympathizing silence during this scene.
“No! but that don’t make any difference. The man that found it first,
and marked it, had a right to it afore the President of the United States,
and that I’ll let ’em know, if it costs me my farm. It’s on old Keene’s
land, and I shouldn’t wonder if the old miser had done it himself,—but
I’ll let him know what’s the law in Michigan!”
“Mr. Keene a miser!” exclaimed the young stranger, rather hastily.
“Why, what do you know about him?”
“O! nothing!—that is, nothing very particular—but I have heard him
well spoken of. What I was going to say was, that I fear you will not
find the law able to do anything for you. If the tree was on another
person’s property—”

You might also like