Data Profiling in Python: Understanding Distributions, Time, and Patterns (Part 2)
From the publisher’s feed, collected in the ZeroLabs newsroom.
When Structure Is Clear, Behavior Comes NextIn Part 1, we intentionally resisted the urge to clean, transform, or model the data. Instead, we focused on something far more fundamental: understanding what the dataset is, how it is structured, and what assumptions are safe to make.That foundation matters, because data does not become meaningful simply by existing in rows and columns. Meaning emerges from behavior. How values spread. How they change over time. How columns relate to one another. And how easily the eye can be misled when those behaviors are examined carelessly.Part 2 begins where Part 1 intentionally stopped.Now that we understand the structure of the dataset, we can start asking deeper questions. Not “how do I fix this data,” but “how does this data behave.”What This Part Is AboutThis article focuses on behavioral data profiling, the step where raw structure turns into insight.We will explore:how distributions reveal more than averages ever canwhy visual inspection is powerful but dangerous when done casuallyhow time-based data quietly breaks intuitionhow apparent relationships can mislead when context is ignoredThese are not academic concerns. These are the exact points where dashboards lie, models overfit, and business decisions drift away from reality.Why We Are Continuing With the Same DatasetWe will continue using the Flights dataset from Seaborn.Not because it is complex, but because it is familiar and deceptively simple. This allows us to focus entirely on how to think, not how to wrangle messy files. The patterns we uncover here are the same ones that appear in production datasets across finance, operations, retail, and analytics platforms.Every line of code in this article can be run locally in VS Code or Jupyter, just like in Part 1.What We Will and Will Not Do in Part 2In This Part, We Will:profile numeric distributions properlyexamine temporal patterns and seasonalityvisualize data with intentiontest assumptions using simple checksidentify misleading correlationsWe Will Not:build predictive modelsclean or impute valuesoptimize performancejump to conclusionsThis is still profiling. We are learning how the data behaves before we decide what to do with it.The Objective of Part 2By the end of this article, you should be able to:recognize when averages are hiding important variationspot misleading visual patterns earlyunderstand how time changes interpretationavoid common traps in exploratory data analysisask better questions of your dataPart 2 is where many analysts become overconfident. Our goal is to do the opposite.A Mindset Worth KeepingVisualizations feel intuitive. Numbers feel objective. Both can mislead when context is ignored.Behavioral profiling is about slowing down again, just enough to make sure that what looks obvious is actually true.In the next section, we will begin with distribution profiling, and you will see why a single average can hide the most important story in your dataset.Let’s continue.Step 1: Why Distributions Matter More Than AveragesAverages are comforting. They reduce complexity into a single number and make datasets feel understandable. Unfortunately, they are also one of the most common sources of analytical mistakes.Two datasets can have the same average and behave completely differently. One may be stable and predictable, while the other may be volatile, skewed, or dominated by extreme values. If you only look at summary statistics, both appear identical.That is why experienced data scientists always ask the same question early on:How is the data actually distributed?Step 2: Start With Numeric Distributions, Not ChartsBefore plotting anything, let’s remind ourselves what numeric columns we are working with.df.select_dtypes(include="number").columnsIn this dataset, the key numeric column is passengers. This represents monthly passenger counts, aggregated over time.Now look again at the summary statistics, but this time with intent.df["passengers"].describe()This output gives useful context, but it does not describe shape. The mean and median might be close or far apart. The standard deviation might look reasonable. None of this tells us whether values are evenly spread, skewed, or clustered in certain ranges. Summary statistics are necessary, but they are never sufficient.Step 3: Visualizing the Distribution ProperlyNow we visualize the distribution.import matplotlib.pyplot as pltplt.figure(figsize=(8, 5))plt.hist(df["passengers"], bins=20)plt.xlabel("Number of Passengers")plt.ylabel("Frequency")plt.title("Distribution of Monthly Passenger Counts")plt.show()This single plot immediately tells us more than the table above. We can see whether values are concentrated, whether there is skew, and whether extreme values exist. This is why distribution plots come before modeling. Models assume shapes. If you do not understand the shape, you do not understand the data.Step 4: Identifying Skewness Without Overthinking ItNow let’s quantify what we are seeing.df["passengers"].skew()A positive skew indicates a longer tail on the right side of the distribution.Skewness matters because many statistical methods and machine learning algorithms implicitly assume symmetric or near-normal distributions. When data is heavily skewed, averages become misleading and error metrics behave differently. You do not fix skewness here. You simply acknowledge it exists.Step 5: Comparing Mean and MedianA quick but powerful check.df["passengers"].mean(), df["passengers"].median()When the mean is noticeably higher than the median, it usually indicates right-skewed data. This tells you that a smaller number of high values are pulling the average upward. In business terms, this often means growth phases, seasonal peaks, or structural change over time. Ignoring this difference leads to false baselines.Step 6: Distribution Changes Over TimeDistributions rarely stay stable in time-based data. Let’s check that assumption.df.groupby("year")["passengers"].mean().head()Now compare early and late periods.df.groupby("year")["passengers"].mean().tail()If the distribution shifts over time, treating the dataset as a single homogeneous population becomes incorrect. This is one of the most common mistakes in time-series analysis. Data that looks skewed overall may be relatively stable within smaller time windows. Profiling helps you see that before you aggregate blindly.Step 7: Why Global Distributions Can MisleadLet’s visualize passengers by year.plt.figure(figsize=(8, 5))df.boxplot(column="passengers", by="year", rot=90)plt.title("Passenger Distribution by Year")plt.suptitle("")plt.xlabel("Year")plt.ylabel("Passengers")plt.show()This plot reveals something critical. The distribution itself evolves. What looks like outliers early on become normal later. This is why global thresholds and one-size-fits-all rules often fail in time-based data. Context matters more than absolute values.Step 8: A Common Analytical Trap to AvoidAt this point, it may be tempting to say the data is simply increasing over time and move on.That would be premature.What we have observed is:non-uniform distributionsshifting central tendenciestime-dependent variabilityThese observations should change how you think about cleaning, scaling, and modeling later. They are not conclusions. They are constraints.Step 9: Time and Seasonality — Where Intuition Fails FastestTime-based data looks familiar, which makes it dangerous.Everyone expects trends. Everyone expects seasonality. The problem is that most people see patterns before they verify them, and once the brain locks onto a story, it becomes hard to let go.In this section, we will profile time and seasonality carefully. Not to confirm what we expect, but to test whether those expectations are actually supported by the data.Step 10: Reconstruct Time ExplicitlyFrom Part 1, we already know that time is split across two columns: year and month. Pandas does not treat this as time by default. That means we must be explicit before doing anything temporal.First, let’s create a proper time index.df["month_num"] = pd.to_datetime(df["month"], format="%b").dt.monthdf["date"] = pd.to_datetime( df["year"].astype(str) + "-" + df["month_num"].astype(str), format="%Y-%m")Now confirm what we created.df[["year", "month", "month_num", "date"]].head()Time that is not explicitly encoded is a liability. Many subtle bugs in forecasting and trend analysis come from treating loosely structured time as continuous or ordered when it is not. Creating a clear time representation early prevents silent logical errors later.Step 11: Observe the Time Series Before Interpreting ItNow let’s visualize the full time series.plt.figure(figsize=(10, 5))plt.plot(df["date"], df["passengers"])plt.xlabel("Year")plt.ylabel("Passengers")plt.title("Monthly Passenger Counts Over Time")plt.show()This plot is informative, but it is also misleading if taken at face value. It combines trend, seasonality, and changing variance into a single line. At this stage, the goal is not to explain the pattern. The goal is simply to acknowledge that multiple effects are present.Step 12: Separating Trend From Seasonality ConceptuallyBefore applying any statistical decomposition, we should ask a simpler question.Does passenger volume behave similarly in the same month across different years?Let’s compute average passengers per month.df.groupby("month")["passengers"].mean().sort_values()Now visualize it.plt.figure(figsize=(8, 5))df.groupby("month")["passengers"].mean().plot(kind="bar")plt.xlabel("Month")plt.ylabel("Average Passengers")plt.title("Average Monthly Passenger Volume")plt.show()This step reveals seasonality without any advanced techniques. Certain months consistently show higher or lower averages. This matters because seasonality can dominate trends and distort comparisons. Ignoring it leads to false conclusions about growth, decline, or anomalies.Step 13: Month-Level Variability Across YearsAverages alone can hide instability. Let’s examine variability.df.groupby("month")["passengers"].std().sort_values()Some months are not just high or low, they are unpredictable. High variability signals risk. In operational or business contexts, this often matters more than the average. Profiling variability early helps you understand where uncertainty lives in the data.Step 14: Year-over-Year Comparisons Without OverplottingInstead of plotting everything at once, we simplify.df.pivot(index="month", columns="year", values="passengers").head()Now compute relative change.yearly_growth = ( df.groupby("year")["passengers"].sum().pct_change())yearly_growth.head()Growth rates often tell a different story than raw values. A dataset may show increasing volume but decreasing relative growth. Without checking both, analysts often mischaracterize maturity, saturation, or decline.Step 15: A Common Seasonality TrapAt this point, it is tempting to say the dataset has clear seasonality and a clear upward trend.That statement is incomplete.What we actually know is:seasonality existstrend existsvariance increases over timeWhat we do not yet know is whether these patterns are stable, whether they interact, or whether they distort downstream modeling assumptions.Profiling identifies these questions. It does not answer them prematurely.What Time Profiling Has Shown UsFrom temporal profiling alone, we now understand that:time must be constructed explicitlyseasonality is strong and consistentaverages hide volatilityvariance changes over timeThis knowledge will directly influence how we clean, scale, and model the data in Part 3.Step 16: Correlations and Traps — When Patterns Lie ConvincinglyCorrelation is seductive.Two variables move together and our instinct immediately asks why. The problem is that correlation answers a very narrow question, while our brains rush to much broader conclusions. In data analysis, this is one of the fastest ways to confuse coincidence with insight.In this section, we will profile correlations carefully, not to prove relationships, but to understand how easily they can mislead.Step 17: Start With the Obvious CorrelationIn our dataset, there are only a few numeric columns, but one correlation is unavoidable: time and passenger count.Let’s quantify it.df[["year", "passengers"]].corr()This correlation is strong, but it tells us very little. Time almost always correlates with cumulative growth in operational datasets. Treating this as a meaningful relationship rather than a structural artifact is a common analytical mistake. Correlation here confirms trend, not causation.Step 18: Visual Correlation Can Be More Dangerous Than NumericLet’s visualize the same relationship.plt.figure(figsize=(6, 5))plt.scatter(df["year"], df["passengers"])plt.xlabel("Year")plt.ylabel("Passengers")plt.title("Passengers vs Year")plt.show()Scatter plots feel intuitive, which makes them risky. The visual pattern looks convincing, but it collapses multiple dimensions into one. Month-level seasonality, variance changes, and aggregation effects all disappear. Visual correlation often oversimplifies reality rather than revealing it.Step 19: Correlation Changes When Context ChangesNow let’s compute correlations within each year.df.groupby("year")[["month_num", "passengers"]].corr().head()This is where many assumptions break. Relationships that look strong globally weaken or disappear when examined locally. Context matters. Correlation across the entire dataset may exist simply because of time progression, not because of a meaningful relationship between variables.Step 20: Aggregation Creates Artificial CorrelationLet’s aggregate passenger counts by year.yearly_totals = df.groupby("year")["passengers"].sum()yearly_totals.corr(pd.Series(yearly_totals.index))Aggregation almost always increases correlation strength. This is not insight, it is mathematics. Larger totals accumulate over time, so correlation with time becomes inevitable. Treating this as evidence of a causal relationship leads to flawed narratives and incorrect decisions.Step 21: A Subtle but Common TrapImagine we add another variable later, such as fuel cost, ticket price, or aircraft count. It is very easy to find correlations between these variables and passenger volume.The trap is assuming that correlation implies influence.In time-series data especially, many variables move together simply because they share time as a common driver. Without careful profiling, correlation becomes a storytelling tool rather than an analytical one.Step 22: What Correlation Is Actually Good ForCorrelation is not useless. It is just limited.Used correctly, it helps:identify redundancyflag unexpected relationshipsguide deeper investigationUsed incorrectly, it:replaces reasoning with numbersencourages false confidencehides structural dependenciesProfiling teaches you when correlation deserves attention and when it deserves skepticism.What We Learned in Part 2Across distributions, time, seasonality, and correlation, we uncovered a consistent theme.Data behavior is layered.Averages hide variation.Visuals hide context.Correlations hide structure.Only by profiling each layer deliberately do we avoid misleading ourselves.Closing Part 2: Why This Step MattersPart 2 is where many analyses quietly go wrong. The data looks understandable. Patterns appear obvious. Charts look convincing.But obvious patterns are often the most dangerous ones.Profiling behavior forces you to slow down again, question intuition, and test assumptions before conclusions harden into beliefs.This is not caution for its own sake. This is how reliable analysis is built.Final Thoughts: Why This Sequence MattersAcross the first two parts of this series, we deliberately resisted the urge to move fast.In Part 1, we focused on structure. We learned how to approach an unfamiliar dataset without assumptions. We examined shape, data types, missing values, categorical behavior, and hidden ordering issues. Most importantly, we built a clear mental model of what the data represents. That step alone eliminates a large class of downstream errors that many analyses never recover from.In Part 2, we moved from structure to behavior. We explored how the data is distributed, how averages hide variation, and how distributions change over time. We examined seasonality and temporal patterns, and we saw how intuition often breaks when time is involved. We also addressed correlation and the traps it creates, especially in time-based data, where shared trends can masquerade as meaningful relationships.At this point, we have not cleaned the data. And that is exactly the point.What we have done instead is build understanding. We now know how the data behaves, where assumptions break, and which patterns are real versus structural artifacts. That understanding is what turns cleaning from guesswork into engineering.In Part 3, we will finally clean the data, but every decision will be intentional. We will address transformations, encoding, scaling, and consistency based on evidence gathered in Parts 1 and 2. Nothing will be changed simply because it is common practice. Each step will be justified by what the data has already shown us.This is the difference between working quickly and working correctly.Good data science is not about clever models or impressive charts. It is about sequence. Understand first. Observe behavior next. Clean with intent. Only then does modeling deserve attention.If This Series Is Useful to YouIf this article helped you think more clearly about how to approach data profiling, exploratory data analysis, or real-world datasets, consider following me here on Medium. More parts in this series, and similar deep dives into practical data science, are coming.If you have faced similar challenges in your own work, share your experience in the comments. Real-world discussions add far more value than isolated examples.And if you found this useful, leaving a clap helps others discover it and encourages thoughtful content like this to keep going. Thanks !!!Thank you for reading.Data Profiling in Python: Understanding Distributions, Time, and Patterns (Part 2) was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.