Descriptive statistics and univariate EDA: describing the data, one variable at a time, before any model.
Knowledge Discovery in Data · University of the Philippines Cebu
The typical value and the spread of values around it: mean, median and std.
Where values cluster and in which direction the tail extends: histograms and boxplots.
Counting categories that have no mean, and the checklist that starts every EDA.
This week the analysis-ready table from week 6 is used to answer the most basic question: what each column looks like.
Describing a class by its grades, that is, the typical grade, the gap between best and worst, and whether most sit near the top or the bottom; this week does the same for any column.
One variable at a time. Relationships between variables are next week.
Exploratory data analysis: looking at data with summaries and charts before testing any idea.
e.g. run describe() and draw a histogram before any model
One measured characteristic that changes from row to row: in a table, one column. Not a Python variable, which is a name holding a value.
e.g. budget is a variable of each project; x = 5 is a Python variable
How a variable's values are spread out: which are common, which are rare, where they bunch up.
e.g. most budgets are ₱10–70M; a few reach ₱1.45B
The ordinary average: add all the values, divide by how many there are.
e.g. [2, 3, 4, 11] → 20 ÷ 4 = 5
The middle value once sorted (the average of the middle two if the count is even). Half below, half above.
e.g. [2, 3, 4, 11] → (3 + 4) ÷ 2 = 3.5
The value that appears most often. The only "typical" that works for words.
e.g. ["M", "L", "M", "S"] → "M"
Largest value minus smallest value: the full width the data covers.
e.g. [2, 3, 4, 11] → 11 − 2 = 9
How spread out values are: the average squared distance from the mean (pandas divides by n − 1).
e.g. [2, 4, 6]: mean 4, squared distances 4, 0, 4 → 8 ÷ 2 = 4
The square root of the variance: how far a typical value sits from the mean, in the column's own units.
e.g. [2, 4, 6] → √4 = 2; in pandas .std()
The p-th percentile has p% of the values below it. Quartiles are the 25th, 50th and 75th percentiles: Q1, median, Q3.
e.g. if the 90th percentile of scores is 85, nine in ten scored below 85
Interquartile range: Q3 − Q1, the width of the middle half. Extreme values barely move it.
e.g. Q1 = 71, Q3 = 88.5 → IQR = 17.5
Lopsidedness. Right-skewed: a long tail of large values (mean above median). Left-skewed: the mirror image. About 0: symmetric.
e.g. incomes are right-skewed: a few people earn far more
A bar chart of one numeric column: each bar counts how many values fall in one range.
e.g. ax.hist(income, bins=6)
The equal-width ranges a histogram counts into. More bins give narrower bars, more detail and more noise.
e.g. scores 0–100 in 10 bins: 0–10, 10–20, …
A picture of the quartiles: a box from Q1 to Q3, a line at the median, whiskers, and dots for outliers.
e.g. df.boxplot(column="budget")
Each category with how many times it appears (or its share). pandas builds it with value_counts().
e.g. Visayas 6, Mindanao 4, Luzon 2
"Exploratory data analysis, John Tukey's term, means examining the data with as few preconceptions as possible and letting it suggest the questions worth asking, before any hypothesis is tested."Description precedes modelling
EDA (exploratory data analysis) means looking at the data with summaries and charts before testing any idea. A hypothesis is an idea to be tested, e.g. "bigger projects take longer". Without EDA, precise answers are computed for questions that were never checked.
A doctor takes a temperature and examines the patient before ordering an expensive scan; EDA is that first examination.
CRISP-DM is week 2's six-step map of a data project. This week sits in its Data Understanding step, which the diagram returns to repeatedly because inspection changes the questions.
Mary Eleanor Spear draws an early form of the box plot.
Tukey founds Princeton’s statistics department; he also works at Bell Labs.
Tukey introduces the box-and-whisker plot.
Exploratory Data Analysis is published.
Tukey also coined the word bit and was the first to use software in print, in 1958.
Tukey’s point: look at the data before testing a theory about it, so the data can suggest which questions are worth asking.
Built into matplotlib, seaborn and pandas: df.boxplot().
The Cooley–Tukey fast Fourier transform (1965) underlies audio, image and signal processing.
His word for a binary digit is now the unit of all digital information.
This week’s describe() and box plots are Tukey’s exploration in two lines of pandas.
As in week 6, a block with a ▶ Run / Edit button runs in the browser and can be changed and run again. The first run downloads Python and pandas, which takes 10 to 20 seconds; charts appear as pictures.
The small examples run here. Blocks that download the flood data have no button: the companion notebook runs them. The browser runs pandas 2.2, so text columns print as object instead of str.
pd.__version__the installed pandas: 3.0.5 on the laptop, 2.2.0 in the browsert.dtypeseach column’s type: str on the laptop, object in the browserTwo numbers that together summarize a variable.
Loading a table and selecting one column were covered in weeks 4–6. This part adds the numbers that describe that column: where its middle is (the centre) and how far its values lie from it (the spread).
describe(): a full summary in one callCount, centre, spread and quartiles for a numeric column. It is run on every column before any conclusion is drawn.
scores is a pandas
Series (one column of values) holding 12 exam scores.
.describe() is a method: a function that belongs to the Series and is
called with a dot.
Result on the lecture laptop (select to reveal)
The median is 81.0, halfway between the 6th and 7th sorted scores (79 and 83). With 195: the mean rises to 86.75, the std to 36.0 and the max to 195.0; count, min, the quartiles and the median do not move.
count 1212 values that are not missingmean 78.42the ordinary average: 941 ÷ 12std 12.70standard deviation: a typical score sits about 12.7 points from the mean25% / 50% / 75%the quartiles: a quarter of scores are below 71, half below 81, three quarters below 88.5min / maxlowest and highest score: a first check for unusual valuesThe 25% / 50% / 75% rows are the Q1,
median and Q3 from week 5's IQR fences, now used for description rather than outlier detection.
50% = the medianHalf the values below, half above. A statement about order, so extremes barely move it.
The box in a boxplot. It contains the usual values, regardless of the tails.
Week 5 used them to flag outliers; this week they describe the bulk of the data.
Quartiles are about order, not size: the scores are sorted, and Q1, the median and Q3 sit 25%, 50% and 75% of the way along the row. A quartile can fall between two scores; pandas then takes the value proportionally between them (Q1 lies three-quarters of the way from 68 to 72).
The shaded middle half is the box of a boxplot, and the fences are week 5’s outlier rule. No score here lies outside them.
On tight, symmetric data they are nearly equal. One very large value moves the mean towards it, while the median is unchanged.
If a billionaire joins 49 teachers on a bus, the mean wealth becomes tens of millions while the median passenger is still a teacher.
Result on the lecture laptop (select to reveal)
11.6 and 12.0, then 33.2 and 12.0. With 1200 the mean jumps to 249.2; the median stays 12.0, because it depends only on the middle value.
pd.Series([10, 12, 11, 13, 12])one column of five valuesprint(a, b)print both numbers on one line: the mean first, then the median11.6 12.0mean (10 + 12 + 11 + 13 + 12) ÷ 5 = 58 ÷ 5; median: sorted 10, 11, 12, 12, 13, the middle one33.2 12.0166 ÷ 5; the 120 alone lifts the mean. Sorted, the middle value is still 12For skewed data (incomes, house prices, wait times) the median is the appropriate "typical" value. Reporting both is better, since their gap is itself informative.
in the tight row the mean (▲) and median (|) coincide. In the skewed row the single 120 drags the mean to 33.2, far from every actual value, while the median stays at 12 with the other four.
Standard deviation (SD, std) measures how
far values typically sit from the mean. The range is the largest minus the smallest value. Two series can have the same centre and differ in every other respect.
wild to [30, 70, 50, 50, 50]. What happens to the SD and the range?Result on the lecture laptop (select to reveal)
wild: SD 31.6 against calm’s 0.7, with the same mean of 50. With [30, 70, 50, 50, 50] the SD falls to 14.1 and the range to 40; the mean is still 50.
round(calm.std(), 1)the standard deviation, rounded to one decimalcalm.max() - calm.min()the range: largest minus smallest50.0 31.6 80mean, SD, range: the same centre as calm, forty-five times the spreadA river with an average depth of 1 meter can still have dangerously deep parts. The mean does not describe them; the spread does. The next slide computes the SD of wild by hand.
Take wild = [10, 90, 30, 70, 50], whose mean is 50. Four steps turn the distance from the mean into one number.
| Value | Distance from 50 | Squared |
|---|---|---|
| 10 | −40 | 1,600 |
| 90 | +40 | 1,600 |
| 30 | −20 | 400 |
| 70 | +20 | 400 |
| 50 | 0 | 0 |
Squaring prevents the negative and positive distances from cancelling out; the square root at the end turns the answer back into the original units.
wild - wild.mean()subtracts 50 from every value at once: the distances(…)**2 … .sum()square each distance and add them up: 1,600 + 1,600 + 400 + 400 + 0wild.var()the variance: that total divided by n − 1 = 4 (pandas' choice for a sample)wild.std()√1000 ≈ 31.6: a typical value is about 32 away from 50
both rows balance on the dashed line at 50. Each black bar spans the mean ± one standard deviation: 0.7 for calm, barely visible, and 31.6 for wild. The mean alone does not distinguish them.
The same summaries, now on the 34,079 flood control projects. The download is week 6’s, and so is the derived duration column that a later slide uses.
pd.read_csv(url)?pandas downloads with urllib, which this site’s bot protection answers with 403 Forbidden. requests gets through.
The browser cannot download the data, so the flood blocks have no Run button; the companion notebook runs them.
requests.get(url)download the whole table in one requestdf["duration"] = …days from start to completion (week 6); NaN where a date is missing(34079, 16)34,079 projects; 15 columns from the file plus durationOne call gives every summary from Part A. It is read top to bottom before anything is plotted. df is the flood-control table (34,079 projects); df.budget is a shortcut for df["budget"], its budget column in pesos.
They differ by ₱9.3 million here. On a symmetric distribution (the left half a mirror image of the right) they would be nearly equal. This one is skewed.
pd.set_option(…)a display setting, as in week 5: show numbers with commas and no decimalsmean 46,952,340the average project budget: about ₱47 million50% 37,676,233the median: half the projects cost less than ₱37.7 millionmin 0 / max 1,447,499,996some rows record a zero budget; the biggest is ₱1.45 billionEvery statistic it printed describes only the remaining rows.
duration is the column built in week 6: days from start date to completion date. Summarized on a 34,079-row frame, it gives count 27,664. pandas raised no error and no warning; it excluded the missing values and continued.
Exactly the On-Going, For Procurement and Not Yet Started projects from week 5. Therefore "median duration 202 days" means "median duration of projects that finished".
len(df)counts the rows of the tabledescribe()["count"]selects one line of the summary by its label: how many values were actually used (27664.0 has a decimal because describe() stores every line as a decimal number)isna().sum()isna() marks each missing cell (NaN) True; .sum() counts the Trues, because True counts as 10.1886,415 ÷ 34,079: almost one row in five has no durationImplies all 34,079. It describes a population that was never measured, since unfinished projects have no duration by definition.
It is what .describe() appears to say, and only the count line in the output contradicts it.
States the population, the count and the statistic. A reader can check it and knows what it excludes.
State the denominator in the sentence. If it cannot be stated, the measured quantity is not yet understood.
This is survivorship bias again (week 5): drawing a conclusion only from the cases that got through a filter. Here the filter is "has finished", and a summary function applied it automatically.
The denominator is the "out of how many" behind a number. "Median 202 days" is out of 27,664 finished projects, not all 34,079, and the report should say so.
Every project affects it, including the ₱1.45B one. It is the balance point, not the typical case.
Half of projects cost less than this. If the largest project rose to ₱10B, this number would not change.
Quoting the mean makes the typical project appear a quarter more expensive than it is.
Neither is wrong. But "the average flood control project costs ₱47 million" describes an arithmetic property; "half cost under ₱38 million" describes a project. The intended meaning should be stated.
The mean is the balance point of a ruler with every budget placed on it as a weight, so one heavy weight far to the right moves it; the median is the middle weight and is unaffected by the last one.
₱48.6M of standard deviation (SD) against a ₱37.7M median is a warning in itself. For bell-shaped data, about 95% of values sit within 2 SDs of the mean (the "mean ± 2 SD" rule). Here that range would reach below zero.
It assumes a roughly symmetric distribution. For skewed amounts, percentiles are preferable because they are always interpretable.
round(df.budget.std())the standard deviation of every budget, rounded to whole pesos46_952_340the underscores are digit separators, like commas; Python ignores them-50236298about −₱50.2M: mean minus two SDs is a negative budget: impossible, so the bell-shape rule does not applySkewness (skew) puts a number on lopsidedness. Positive means a long tail of large values; negative, a long tail of small ones. Roughly: |skew| (the size, ignoring the sign) under 0.5 is symmetric, over 1 is strong.
Kurtosis measures how often extreme values turn up. A normal distribution (the symmetric bell curve) scores 0 in pandas. 76 means extreme values are far more common than a bell curve would predict.
np.random.default_rng(0).normal(size=34079)NumPy draws 34,079 random numbers from a bell curve (the 0 is a seed, so the draw repeats exactly)round(pd.Series(bell).skew(), 4)wrap them in a Series so pandas can measure the skew, rounded to 4 decimals: about 0, as a symmetric shape should beFor skewed data, a set of percentiles is the preferred summary. The p-th percentile is the value with p% of the data below it. Each one is directly interpretable without assuming any shape.
₱212M. Projects above it are the top 1% of 34,079 contracts, a much clearer threshold than "two standard deviations".
quantile([.05, .25, …])a list of fractions: .05 asks for the 5th percentile, .5 for the median(p / 1e6).round(1)divide by one million (1e6) and keep one decimal, so ₱96,499,614 reads 96.50.90 96.590% of projects cost less than ₱96.5 million| Slice of projects | Count | Share of total spend |
|---|---|---|
| Top 1% by budget | 340 | 6.5% |
| Bottom 50% by budget | 17,039 | 16.5% |
| The middle | 16,700 | 77% |
Reading the first row: the 340 largest projects (the top 1%) add up to 6.5% of all the money. A univariate (one-column) summary answered a question about public spending: the money is spread more evenly than the ₱1.45B headline project suggests. The budget is not concentrated in the largest projects.
A single extreme value attracts attention but summarizes the data poorly.
the dashed diagonal is what equal budgets would give. The curve runs below it: the smaller half of projects holds 16.5% of the money, the “Bottom 50%” row of the previous slide. A few dominant projects would push the curve much closer to the bottom edge.
Two sections took the same exam. Both average 75. Section A's std is 3; Section B's is 18. Which section is of greater concern?
C: the spread reveals students who are struggling.
With std 18, Section B plausibly has students in the 40s, which Section A does not. The means are identical but the classes differ, which is why a mean is reported with its spread.
Centre describes the typical value. Spread describes how far values range around it.
Report centre and spread together.
Next: shape, which the summary numbers do not show.
The shape of a distribution is shown by plotting it.
A column can now be summarized in a few numbers. Numbers hide the shape; this part plots it, with histograms, box plots and a log scale.
The range is divided into bins (equal-width ranges, like 15–20k, 20–25k), the values in each are counted, and each count is drawn as a bar. Clusters, gaps and tails become visible, which no single number can show.
People grouped by height band (150–155 cm, 155–160 cm…), where the length of each queue is a bar.
bins=6 to bins=3. What happens to the 60k income, and to the rest?Result on the lecture laptop (select to reveal)
10 of the 12 incomes are in the tallest bar (15k to 22.5k); one more sits in the next bar, and the 60k income stands alone at the right. With bins=3 the other eleven merge into one bar of 11, and 60k is still alone. The next two slides show both charts.
fig, ax = plt.subplots()start a blank chart: fig is the whole picture, ax the plotting area (matplotlib, imported as plt)ax.hist(income, bins=6)income is a Series of 12 incomes (in thousands); count them into 6 equal-width bins, one bar per binset_xlabel / set_ylabellabel the axes: what is across, what is upplt.show()display the finished chartFirst the tallest bar (where most values are), then the number of peaks, then the direction of the tail.
the tallest bar holds most of the data: 10 of the 12 incomes lie between 15k and 22.5k. An empty gap follows, and one income (60k) stands alone at the far right. That long stretch to the right is the tail.
The same twelve incomes with bins=6 and bins=3: the outlier (60k)
stands alone in both, but with bins=3 all eleven other incomes merge into one bar and the 23k income is no longer distinguishable. Neither is the correct picture; both are choices.
Bins resemble the mesh of a fishing net, where large holes put everything into one catch and small holes give every fish its own pocket.
Everything merges into one block; structure and outliers disappear.
Every value gets its own bar, and noise appears as pattern.
Try several bin counts before drawing conclusions. A "finding" that appears at only one bin setting is probably an effect of the bins.


left, the previous slide's code with bins=6; right, the same code with bins=3. The 60k income stays alone either way, because it is far from everyone else. What changes is the bulk: at 3 bins it is one block of 11, and the slight separation of 23k is no longer visible.
Everything above (the skew, the heavy tail, the gap between mean and median) appears in one picture, which should be plotted before the numbers are trusted.
With a ₱1.45B maximum, 95% of the data falls into the first four of 50 bars. The range is limited, and the limit is stated.
df.budget.hist(bins=50)pandas' shortcut: draw a histogram of the column with 50 bins (it draws a picture and prints nothing; the # → comments describe the result)2e8e-notation: 2 followed by 8 zeros, i.e. 200,000,000 (₱200 million)df.budget[df.budget < 2e8]keep only budgets under ₱200M (a boolean filter: keep the rows where the test is True), then draw those

left, df.budget.hist(bins=50): the first bar alone holds 14,564 projects (43%) and everything past ₱0.3B is nearly empty (1e9 = billions of pesos). Right, the clipped version (1e8 = hundreds of millions) shows spikes just under ₱50M and ₱100M. Run each line in its own cell; in one cell pandas draws both on the same axes.
| Bins | Bin width | Tallest bar holds | Appearance |
|---|---|---|---|
| 10 | ₱20.0M | 11,817 projects | One dominant block; detail lost |
| 30 | ₱6.7M | 4,891 projects | A clear peak and tail; usable |
| 100 | ₱2.0M | 3,192 projects | Spiky; noise becomes visible |
Bin width is the range divided by the number of bins: the ₱0–200M range ÷ 10 bins = ₱20M per bar. No bin count is correct. 10 hides the shape, 100 invents texture. The recommended practice is to examine several and report one that can be justified, not the one that best supports a conclusion.
Mirror-image around the middle; mean ≈ median. Heights and test scores often look like this.
A long tail toward high values pulls the mean above the median. Incomes, house prices, city populations.
A long tail toward low values; mean below median. Scores on an easy exam: most score high, a few do not.
This connects to Part A: the mean–median gap computed there is the skew visible here. They are two views of one fact.
The tail points to where the few unusual values are. A right tail means a few very large values, which pull the mean towards them.
Mean 22.4, median 19.5: even before plotting, the tail is known to point right.
the sign of the skew points along the tail: positive for a tail to the right, negative for a tail to the left, about 0 for a mirror image. The flood budgets (skew 5.13) lean the same way as the middle panel, more strongly.
A log transform does not delete the outliers; it re-spaces the axis.
log₁₀(x) is the power of 10 that gives x: log₁₀(1,000) = 3, log₁₀(1,000,000) = 6. Each step of 1 means "ten times bigger".
Money is often roughly log-normal: its logs look like a bell curve, because differences that matter are multiplicative (×2, ×10) rather than additive (+₱1M). Plotting log₁₀(budget) turns that shape into a near-symmetric one.
The transform is for visualization. Values are converted back before being quoted, so that readers need not exponentiate.
df.budget[df.budget > 0]keep the positive budgets: the log of 0 does not existnp.log10(…)NumPy takes log₁₀ of every value: ₱10M becomes 7, ₱100M becomes 8round(10**lb.mean())** is "to the power of": undo the log. The result is the geometric mean, a typical value on the multiplying scale
the same projects on two scales. On the right, 7 means ₱10 million and 8 means ₱100 million, so the crowded corner on the left is spread across the full width. The spikes near 7.7 and 8.0 are the clusters just under ₱50M and ₱100M seen in the clipped histogram.
Box = middle half. Line = median. Whiskers = the lines that reach out to the last value inside the fences computed by hand in week 5 (1.5 × IQR beyond the box). Dots beyond = outliers, values far from the rest, drawn automatically.
The lab box-plots the 12 exam scores and matches the box to the quartiles from
describe(): 71, 81 and 88.5.
The box is p25 to p75 (Q1 to Q3). The whiskers reach 1.5×IQR beyond the box: the top fence is 67.5M + 1.5 × 52.9M = 146.9M. Everything beyond is drawn as a point — the same 798 projects week 5 flagged.
One box per region puts 18 distributions side by side, which a histogram cannot do legibly.
q3 + 1.5 * (q3 - q1)week 5’s upper fence: 67.5M + 1.5 × 52.9M = ₱146.9 million(df.budget > fence).sum()798 projects lie above it: the dots on a single national boxdf.boxplot(column="budget", by="region")one box per region, side by side; on skewed data, expect dots: they are the tail, not errors
this is the default output: regions in alphabetical order, names written horizontally, so the 18 labels overlap and cannot be read. The first box (Central Office) sits far above the others; every other box is squashed near zero with a column of outlier dots above it, the skewed tail. 1e9 means billions of pesos. Next week's sorted, horizontal boxplot makes the labels legible.
They summarize the same distribution at different levels of detail, so they answer different questions.
For a first look at a variable, showing its full shape: peaks, gaps and tails.
For a compact summary, especially several side by side: income by region, scores by section.
"Boxplots side by side" is already a two-variable question, which is where Data Exploration II begins.
Household income in a city is strongly right-skewed. Without computing anything: how do its mean and median compare?
A: the tail pulls the mean upward.
A few very high incomes lift the mean well above what a typical household earns; the median stays with the bulk of households. For this reason "median income" is more informative than "average income".
Shape, centre and the mean–median gap are connected: any two determine the third.
The statistic a headline uses is an editorial decision, and week 9 covers making it.
Variables with no mean, and a checklist that covers every column.
Numeric columns can now be described. Text columns such as region or contractor have no mean; this part counts them, then gathers every check into one routine.
A categorical column holds labels, not amounts
(region, status). Its summary is a frequency table: each value and
how often it appears. value_counts() builds it, and with
normalize=True gives each value's share.
print(r.describe()). What does describe() report for text?Result on the lecture laptop (select to reveal)
Visayas holds 0.50 (6 of 12). For text, describe() reports count 12, unique 3, top Visayas and freq 6: counts and the mode, because text cannot be averaged.
r = pd.Series([…] * 6 + …)an example column of 12 region labels: * 6 repeats a label six times, + joins the listsr.value_counts()count the rows for each region, biggest first: 12 rows in totalnormalize=Truedivide each count by the total: 6 ÷ 12 = 0.50. The shares add up to 1 (proportion = share)Counts give "how many"; shares give "how dominant", and shares remain comparable across datasets of different sizes.
The whole Part A toolkit is for numbers. For text columns, the summary is a frequency table, and the "typical" value is the mode: the value that appears most often.
18 regions is groupable. 4,841 contractors is a long tail. 33,325 different descriptions is free text, which requires a different tool.
.head(4)show only the first four lines: Region III holds 15.9% of projectsnunique()how many different values the column hasmode()[0]mode() returns a list-like Series, since two values can tie; [0] takes the first
sorted bars make the frequency table readable at a glance: Region III, the mode, holds 15.9% of projects, and Central Office has only 180. A pie chart of 18 slices would not show this ranking.
Use duration (built in week 6) or progress (percent complete, 0–100). Run .describe().
Compute .skew(). Predict the histogram shape from that number alone, then plot it and check.
10, 30, 100. Choose one for a report and state the reason.
One about the centre, one about the spread, one about the shape — each with a number in it.
Step 4 is the deliverable: three sentences, each stating a number.
Flood budgets have mean ₱46.95M, median ₱37.68M and skew 5.13. Which sentence is the most accurate summary?
Taking log₁₀ of the budget column changes the skew from 5.13 to −0.82. What has this achieved?
describe() → mean-vs-median check → histogram (try bins) → boxplot.
Note the shape and any flagged points.
value_counts() both ways → look for rare levels (a
level is one possible category), typo-twins (the same value spelled two
ways: "Cebu"/"cebu ", as in week 6) and unusual dominance.
And for both kinds: isna().sum(), because week 5 still applies. About ten minutes of routine per dataset reveals most surprises.
"income right-skewed, one extreme value; region 50% Visayas" — three lines of notes guide every later chart and claim.
A histogram requires a choice of bins. The ECDF (empirical cumulative distribution function) does not: for any chosen threshold, it gives the share of the data below it.
Each output is a claim suitable for a report, with no modelling assumption behind it.
df.budget < 1e7compare every budget with 1e7 = 10,000,000: one True or False per project( … ).mean()True counts as 1 and False as 0, so the mean is the share that is True0.064 0.2276.4% of projects cost ₱100M or more, and they hold 22.7% of all the money
the three dotted lines are the thresholds printed on the previous slide: 21.4% of projects lie below ₱10M, 70.9% below ₱50M and 93.6% below ₱100M. The vertical jumps just below ₱50M and ₱100M are budgets clustered under those round figures.
A standard deviation of 48 million pesos and one of 159 days cannot be compared. The coefficient of variation (CV) divides each SD by its own mean, so the units cancel and both become plain numbers.
CV above 1 means the spread exceeds the average, which indicates skew or heavy tails. Budget sits at 1.03.
def cv(x):a small function (week 2): the standard deviation divided by the meancv(df.budget)48.6M ÷ 47.0M = 1.03: the spread is larger than the typical valuecv(df.duration)0.68: durations vary much less, relative to their mean| Region | Projects | Median budget | CV |
|---|---|---|---|
| Region IV-B | 1,467 | ₱37.6M | 1.18: least consistent |
| Region VIII | 1,935 | ₱27.5M | 1.07 |
| Central Office | 180 | ₱144.5M | 1.05 |
| Region III | 5,412 | ₱46.3M | 0.72: most consistent |
Region III has the most projects and the steadiest sizes. Region IV-B has a similar median but far more variation: a few large works among many small ones. Only the spread shows this difference.
These are run in order on every new column. The routine takes about a minute and replaces guesswork with description. Here col stands for any one column (for example df.budget) and threshold for a chosen cut-off number.
The numbers indicate what shape to expect. If the picture disagrees, one of the two is wrong and the discrepancy should be investigated.
col, threshold = df.budget, 1e8name the column and the cut-off once; the six lines then work for any numeric column"Anscombe's quartet: four datasets with the same means, the same variances and the same correlation, but four completely different shapes when plotted. The summary numbers cannot distinguish them; a plot can."F. J. Anscombe, 1973: a well-known argument for plotting data
Summaries compress, and compression loses information. This is acceptable provided the full picture has been examined at least once. (Correlation, next week's topic, is one number for how closely two columns move together.)
Four students can all average 75 (one steady, one improving, one declining, one with a single zero), and only their report cards show which is which.
No conclusion is drawn from statistics that have not been plotted.
the printed table gives each dataset the same mean (7.5) and variance (4.12–4.13) of y, and the fitted lines are identical. Only the plots show a loose cloud, a curve, a line with an outlier, and a single influential point.
Exam scores through describe(), a tight and a skewed series
to compare centres, calm-vs-wild spreads, and an income histogram whose appearance changes with the bins. About 45 minutes.
describe(), mean()/median(), std()
and range, and ax.hist() with labeled axes.
value_counts(normalize=True) for a categorical, and a boxplot related back to week 5's IQR fences.
describe() every column firstCentre, spread, quartiles and extremes in one call, before any conclusion.
A mean is reported with a std; skew determines whether the mean or median is used.
Histograms for the full shape, boxplots for a compact summary; the bin count is a choice that should be varied.
Anscombe's quartet: identical summaries can hide very different data.
Every later analysis starts from this description of each column.
Next week moves from single variables to relationships between variables.
pandas User Guide — "Descriptive statistics" (in Essential basic
functionality): what describe, std and related methods compute. pandas.pydata.org
Look up "Anscombe's quartet" and study the four plots for two minutes.
Both are linked on the course page beside this deck and the lab.
The documentation is a reference; an understanding of skew comes from plotting it in the lab.
Multivariate EDA and visualization: correlations, group comparisons, and plots that show how variables move together.
DS 227 · Knowledge Discovery in Data