Python Review · Learning Materials

English translation

Topics covered

Combine missing-value handling and array conversion into a small function so the same data preparation can be reused across analyses.

Overall workflow

Select rows with missing values → NumPy arrays and functions → Calculate statistics → Match original rows to the plot

Before converting to an array

Define the sample count, feature count, and rules for missing values. Reuse a data processing function to avoid applying different preparation rules to the same measurements.

The roles of summaries and plots

A single mean can hide the distribution and outliers. Place a plot of the same data beside the numerical summary, and check how removing missing values changes the samples.

Worked example

The 3-feature data are rows=[[1,2,3],[2,None,4],[3,4,5],[4,5,6]]. Keep rows containing None in a separate list.

import numpy as np
import matplotlib.pyplot as plt
rows=[[1,2,3],[2,None,4],[3,4,5],[4,5,6]]
complete=[row for row in rows if None not in row]
X=np.asarray(complete,dtype=float)
print(X.shape,X.mean(axis=0))
(3, 3) [2.66666667 3.66666667 4.66666667]

Reference example

View more examples

Reference materials