Visualization and Descriptive Statistics
Nobody can read ten thousand rows. To tell anyone what is in a table you have to reduce it, either to a few numbers or to a picture, and each loses different information. A summary number is exact and fits in a sentence, and it hides the shape of the data: the mean and the median are both called “the average”, and under skew — incomes, prices, review counts, waiting times — they can be far apart, because one extreme value moves the mean and leaves the median where it was. The same split runs through spread: variance and standard deviation are built on sums and inflated by extremes, quartiles and the interquartile range are built on order and are not. An outlier is a question, not an error. It may be a mistake, a different kind of thing, or the most important row in the table, so it is flagged, looked at, and then decided on — never deleted on sight.
A picture shows what the numbers cannot. Anscombe’s quartet is four small datasets with the same means, the same standard deviations, and the same correlation that look nothing alike when drawn, which is why you always draw the data. The chart follows from the kind of question: a histogram for how values are spread out, bars for which group has more, a scatter plot for whether two things go together, a line for how something changed over time. In matplotlib a Figure is the whole picture and an Axes is one plot inside it, and functions that draw on an Axes they are given can be placed anywhere. A chart is honest when the eye gets the right numbers: bars start at zero, a logarithmic axis is announced, labels name the quantity and its unit, periods in a trend are complete, and the title says what to see. A figure without axis labels and units is not yet a result.

Listen
| Speaker | Text |
|---|---|
| Alex | So every data science project reaches this one specific inevitable bottleneck, right? |
| Sam | Oh yeah, the massive pristine data table. |
| Alex | Exactly. You’ve just been handed 10,000 rows of beautifully clean information. But here’s the thing for you guys, since you’re likely graduate data science and analytics students. You know that no manager, no client is going to read 10,000 rows. |
| Sam | No, never. The human brain just cannot, you know, extract patterns from a raw matrix of that size, |
| Alex | right? You have to reduce it. |
| Sam | Yeah, reduction is basically a biological necessity for decision making, but it comes with a structural cost |
| Alex | because every time you reduce data, you lose something. |
| Sam | Exactly. Every time you collapse thousands of data points into a single summary statistic or even a two-dimensional plot, you are destroying information. |
| Alex | You’re projecting this complex reality into like a shadow. I always say summarizing data is functionally identical to cutting a movie trailer. Oh, I like that analogy. Yeah, because you have hours of footage, but you only have 2 minutes to tell the audience what the film is about. So you have to leave massive amounts of context on the cutting room floor. |
| Sam | And depending on what you cut, you can completely change the vibe. |
| Alex | Exactly. You can make a lighthearted rom-com look like a psychological thriller just by picking the wrong scenes. So our mission in this deep dive today is to make sure your trailer doesn’t lie to your audience, |
| Sam | which is a huge challenge. And since we are talking to analytics students, we are skipping the textbook definitions today. You already know how to calculate a media, and we don’t need to explain that. We are going straight into the trenches, real world business use cases, the massive data sets you’ll actually face, and exactly why statistical methods and Visualization are your only hope for checking data quality |
| Alex | because describing data honestly is really the core engineering challenge here. We aren’t predicting the future today. We aren’t testing hypotheses. No, |
| Sam | we are simply trying to honestly render what currently exists in a data set. And it is wild how easily summary statistics can obscure the actual business reality. |
| Alex | OK, let’s look at a real example. The financial regulator field data. |
| Sam | Oh, that’s a classic one. Yeah, |
| Alex | so this data set has 1.3 million consumer complaints. And they are leveled against about 5,275 different financial companies |
| Sam | over a seven year period, |
| Alex | right? Exactly. So, you run a basic descriptive summary on the complaints per company. The mean number of complaints per company is 243. But the median is |
| Sam | 6, and that gap right there, that completely dictates your entire analytical approach because |
| Alex | the typical company in that data set got just 6 complaints in nearly a decade, right? |
| Sam | But the mean is 243. |
| Alex | It implies this environment where hundreds of complaints per company is just standard practice, when in reality, just 10 companies out of over 5000 received half of all those 1.3 million complaints. |
| Sam | Which perfectly shows why relying on a single measure of central tendency is just a massive error in a business context. I mean, neither number is mathematically wrong. |
| Alex | They just answer entirely different questions like the classic salary use case. |
| Sam | Oh yeah, the 10 person firm, |
| Alex | right? So you have a firm of 10 people. 9 employees make between 380 and 600 a year. But the 10th person is the owner and they take home 400k, a slight bump, just a little bit, but suddenly your mean salary is 83k and your median is 48.5k. Wait, so if I’m presenting to a client, isn’t the mean just a liar’s statistic when there’s a massive outlier like that owner? |
| Sam | Well, it feels like it because it misrepresents the lived experience of 90% of the company. But it only misrepresents the situation if you’re answering the wrong question. |
| Alex | What do you mean? |
| Sam | So if a job applicant wants to know, you know, what will I actually make here, the median of 48.5k is the honest metric. It represents the typical central experience, right? |
| Alex | That makes sense. |
| Sam | But if the payroll department needs to forecast the total capital required to fund the company, the mean is literally the only metric that matters |
| Alex | because multiplying the mean of 830 by the headcount of 10. Gives you the exact total payroll budget. |
| Sam | Exactly. If they use the median, the company would be catastrophically underfunded. |
| Alex | Wow. OK. So the metric you choose is entirely dictated by the stakeholder’s objective, |
| Sam | precisely. And more importantly, that massive gap between the mean and median, like the 243 versus 6 in the complaint data, that is a primary diagnostic finding in itself. |
| Alex | It tells you something is up before you even draw a chart. Yes, |
| Sam | it tells you the data is heavily skewed right. You have this massive long taildragging the mean away from the center. |
| Alex | OK, so once you anchor your data with a center, like a mean or median, you have to figure out how wild the data gets. You need to know the spread. Yeah, |
| Sam | if the center is the plot of your movie, the spread is the cast of characters, and some of those characters are absolute wildcards. |
| Alex | I always think of spread like an archery target. The mean is the center of the cluster of arrows, but the spread tells you if all those arrows are tightly packed in the bull’s eye or if they are just scattered erratically across the target, the wall, and the trees behind it. |
| Sam | That’s a great way to picture it. And the mechanics of how we measure that scatter are incredibly sensitive. Usually people default to variance and standard deviation, |
| Alex | right, where variance is calculating the square distance of each point from the mean. |
| Sam | Yeah, and then standard deviation takes the square root to get back to original units, but because variance relies on the mean, it inherits that exact same vulnerability to outliers, |
| Alex | and it doesn’t just inherit it, it amplifies it |
| Sam | right exponentially because of the squaring mechanism. Like if a normal data point is 2 units away from the mean, it contributes 4 to the variance pool. But if a wildcard outlier is 20 units away, it doesn’t just contribute 10 times as much. It contributes 400 to the variance pool. Wow. |
| Alex | So the distance is multiplied by 10, but the penalty is multiplied by 100. |
| Sam | Exactly. A single extreme value can just detonate your standard deviation, making it look like your typical data is way more scattered than it actually is, |
| Alex | which is why we use quartiles and the interquartile range or IQR instead for heavily skewed data sets. Yes, |
| Sam | because IQR abandons the concept of distance entirely. It operates purely on rank and order. |
| Alex | It just measures the width of the middle 50% of your sorted data. |
| Sam | Right? So an extreme outlier, way out at the edge of the data set, literally doesn’t move the calculation at all. It is incredibly stable. |
| Alex | But if you’re calculating these spread metrics programmatically, you’re almost certainly using Python. And this brings us to one of the most insidious traps in data science. |
| Sam | Oh, the pandas versus numpai variance trap. This is a nightmare if you don’t know about it. |
| Alex | We have to highlight this for you listening. If you use pandas and numpai in the same pipeline, they fundamentally disagree on how to calculate variants by default. |
| Sam | You can pass the exact same data into pandas and numpai, same function name basically, and Python will give you two completely different numbers |
| Alex | with zero warnings. It just silently corrupts your validation checks. So what is actually happening under the hood? |
| Sam | It comes down to Bessel’s correction. Pandas assumes your data is just a sample of a larger population, so it divides by the count minus 1 to fix the underestimation bias. Exactly. But numpai assumes your array represents the entire population, so it just divides by the total count. So how do you fix it? To force numpai to match pandas, you have to explicitly pass the argument DDOF equals 1 inside the np.var function, delta |
| Alex | degrees of freedom. |
| Sam | Yep, it forces numpai to subtract one from the denominator. That tiny parameter will save you hours of debugging. |
| Alex | OK, so let’s talk about what we actually do with the outliers driving all this variance. The standard thing is to use the 1.5 IQR fences, |
| Sam | right? Right. You calculate your quartiles, get the IQR, and set statistical fences 1.5 times the IQR above and below that middle half. Anything outside gets flagged. |
| Alex | But here’s the thing. Isn’t an outlier just dirty data we need to scrub out so we can get a nice clean model? |
| Sam | No, absolutely not. Yielding to that instinct is a severe analytical failure. Why? Because a flagged value can be one of three very different things. First, it could be a genuine mistake. Someone typed an extra 0 on a salary or a sensor broke. |
| Alex | OK, in that case, you delete it or impute it. |
| Sam | Sure. The second scenario is that it’s a fundamentally different population mixed in, like the owner’s 4000 salary mixed with entry level staff, |
| Alex | right? So you isolate it depending on what you’re studying. |
| Sam | Exactly. But the third scenario is the most critical. That flagged outlier might actually be the most important row in your entire database, |
| Alex | like a singular client generating most of your revenue. Yes, |
| Sam | if we go back to the regulator data and run that 1.5 IQR rule on the 1.3 million complaints, it flags 778 companies as outliers out |
| Alex | of 5,275 companies. |
| Sam | So deleting 778 might just feel like, you know, an acceptable pruning of the data set, |
| Alex | right. Until you look at the gravity of those rows, those 778 companies account for 96% of all the complaints. So if you just automate the deletion of outliers on site, you are deleting the actual subject of your analysis. |
| Sam | You are modeling a fantasy. The outliers aren’t the noise there. They are the entire signal. An outlier is a prompt for investigation, not an instruction for deletion, |
| Alex | which brings us to the ultimate point. We’ve established that summary numbers hide the shape of the data, and outliers can be the most valuable part. So how do we actually get a feel for the data’s quality? |
| Sam | You have to look at it. You have to draw it. Sums and averages literally cannot differentiate between structural shapes. We |
| Alex | have to map it visually. Like, consider correlation, right? The R value. It measures straight line association, |
| Sam | right, from 1 to -1, but |
| Alex | the operative word is straight line. |
| Sam | It is totally blind to curves. |
| Alex | You could have a data set that forms a beautiful, perfect parabolic curve, and the correlation coefficient will just say, nope, near zero. |
| Sam | It’ll confidently tell you there’s no relationship, and this is exactly what Anscomb’s Quartet proves. Oh, |
| Alex | this is the ultimate Pixar, it didn’t happen moment for data science. It really is. |
| Sam | Anscomb’s Quartet is 4 small data sets, and if you run a standard pandas describe on them, they look completely identical. |
| Alex | Same exact means, same standard deviations. And the exact same correlation of 0.82. |
| Sam | But when you actually draw them on a scatter plot, they are completely different. |
| Alex | The first one is just a normal loose cloud of points trending up. |
| Sam | The second is a perfect smooth curve, which again the 0.82 correlation totally fails to describe because it averaged a curve into a straight line. |
| Alex | The third is a perfectly straight line. But one massive outlier pulls the correlation down, |
| Sam | and the fourth is the craziest one. It’s just a vertical stack of points, zero correlation, but one single point sitting way off to the right creates a mathematical anchor. |
| Alex | It single-handedly manufactures a strong correlation out of nothing. |
| Sam | Exactly. You can run all the statistical readouts you want, but if you don’t map it visually, you might be looking at a curve while your stats tell you it’s a line. |
| Alex | So we absolutely must draw the data to understand it, but just as numbers can lie, a chart can be technically correct and still tell a massive lie to the reader’s eye, |
| Sam | right? Oh, it happens all the time. Building honest pictures in Python requires actual discipline. |
| Alex | Let’s talk about the Python stack for a second. MapPplotlib is the foundation, right? Even if you use Seaborne or Pandass plotting, they are just issuing commands to mapplotlib. |
| Sam | Yep. And to write robust code, you have to know the difference between a figure and an axis. The figure is the whole picture, the blank canvas. The axis is the actual plot inside it. But |
| Alex | so many tutorials just use the pilot state machine. Like PLT.hist or PLD.title, |
| Sam | which is fine for a quick Jupiter cell, but the second you build a complex dashboard, that hidden state machine breaks down. Graphs overwrite each other, |
| Alex | so you have to use the object interface instead. |
| Sam | Exactly. Instantiate your figure and axes explicitly and call methods directly like AX.hist. |
| Alex | OK, so once the code is solid, there are basically two rules for an honest picture. Rule one, the chart follows the question. |
| Sam | Yes. Spread means a histogram or box plot. Comparison means bars. Relationship is a scatter plot, and trend over time is a line chart. Don’t let default parameters decide for you. |
| Alex | And rule two, honest scaling. Because the human eye translates lengths and slopes back into numbers, |
| Sam | which is why bar charts absolutely must start at zero, right? |
| Alex | Because if you have two bars like 50,000 and 53,500, and you cut the axis to start at 50,000, |
| Sam | you’ve basically committed visual perjury. |
| Alex | The tiny 7% difference suddenly looks like one bar is 4 times larger than the other. |
| Sam | What about highly skewed data |
| Alex | like our complaint data set where 10 companies hold all the density. If you put that on a normal linear axis, it’s useless. |
| Sam | It just looks like one massive pillar at zero and a blank chart everywhere else. So you have to use a logarithmic axis, |
| Alex | right? Using functions like nP.geome space to calculate bin edges that scale multiplicatively instead of additively. |
| Sam | It mathematically compresses that long tail so you can actually see the microstructures, but you have to label it clearly or people will misread the leaps. Also, |
| Alex | time periods have to be complete. If you show a line chart of monthly sales and it just plummets in the final month, |
| Sam | it looks like the business collapsed. But then you realize the data export was just pulled on the 10th of that month. |
| Alex | The software just did what it was told. |
| Sam | Exactly. Same with categorical string consistency. If a database admin renames credit reporting to credit reporting debt halfway through the year, the |
| Alex | chart splits your biggest bar into two smaller ones. And suddenly it looks like complaints dropped, but it was just a primary key changing format, |
| Sam | which is why visualization isn’t just about making things pretty for the final presentation. It is your most aggressive data quality check. |
| Alex | It’s how you spot the anomalies like the source material mentioned, a random spike in one month of coffee cart sales or complaint |
| Sam | data, right? Your instinct might be to smooth it out with a rolling average. But if you visualize it and investigate, that spike might map exactly to a massive data breach. |
| Alex | That geometric outlier becomes the most informative point on the chart. |
| Sam | You cannot discover that mechanism just looking at a mean or a median. You only find it by mapping the points to a coordinate system and letting your visual cortex catch what the sums hide. |
| Alex | So if you’re the analyst facing that 10,000 row matrix, your job is rigorous honesty. You have to compute both the mean and the median and explain if they differ. |
| Sam | You have to watch out for those hidden Python defaults. Always enforce sample variants with DDOF equals 1 when using NumPy. |
| Alex | Never blindly delete outliers |
| Sam | and always, always draw the |
| Alex | data, because describing data honestly is really a translation job, and you have to make sure your translation doesn’t lose the reality of the raw data. |
| Sam | Couldn’t agree more. |
| Alex | All right, to wrap up our deep dive today, I want to leave you all with a final provocative thought. It’s inspired by a note in the source material. Most bad charts are a good answer to a question nobody asked. Oh, that is so true, right? So the next time you open up a beautiful, highly complex data dashboard at work or school, ask yourself, are these charts actually answering a specific human question, or did the creator just let the software decide what looked pretty? Because remember, if you don’t know the question beforehand, your perfectly coded matte plot lib figure isn’t an insight, it’s just decorative noise. |
Presentation
Read
- Visualization and Descriptive Statistics (lecture notes)
Hands-on
Notebooks in 09-Visualization-Descriptive-Statistics
Homework
- Homework 8: Same Numbers, Different Pictures — due Wednesday, November 4, 2026