AAmit’s LibraryLEARN · PRACTISE · REFLECT

BCA

Exploratory data analysis with Python: from records to questions

Study map: Original foundation and applied business–computing lesson; related subjects, not a claim of complete unit coverage

Exploratory data analysis investigates the structure, quality and patterns of data before stronger claims are made. Begin with the business question and the meaning of one row. A transaction line, order, customer and daily total represent different grains. Counting rows without knowing the grain can produce a misleading business measure.

1. Define the observation and its origin

Exploratory data analysis investigates the structure, quality and patterns of data before stronger claims are made. Begin with the business question and the meaning of one row. A transaction line, order, customer and daily total represent different grains. Counting rows without knowing the grain can produce a misleading business measure.

Create a data dictionary with names, types, units, allowed values and provenance. Explain whether a timestamp reflects the event or its later recording. In Python, inspect shape, columns, types and sample records before calculating results. A numeric-looking identifier should not automatically be treated as a quantity. Preserve the raw input and record transformations so exploration remains reproducible.

Further reading: pandas getting-started tutorials

2. Inspect missingness, duplicates and distributions

Missing values can reflect nonresponse, unavailable information or a failed process. Zero is a value and should not be substituted without justification. Examine missingness by time, source and relevant groups. A duplicate row may be a repeated upload or a legitimate repeated event; use business identity and context to distinguish them.

Describe numerical distributions with plots and appropriate summaries. The mean is sensitive to extreme values, while the median answers a different question. Investigate unusual observations before removing them. For retail data, a large negative quantity may represent a return rather than an error. Cleaning should follow meaning and documented rules, not an automatic wish for a smooth dataset.

Further reading: Harvard CS50 Python

3. Compare groups and relationships

Group data at the level needed for the question. Revenue by product, customer and month can reveal different patterns. Check denominators when comparing rates: ten complaints among one hundred orders differs from ten among ten thousand. A change in customer mix can alter an overall rate without any subgroup improving.

Use scatterplots and cross-tabulations to investigate relationships, but distinguish association from causation. An observed relationship between discount and sales can reflect the products chosen for promotion. Record hypotheses generated through exploration and test them with an appropriate later design. Avoid reporting every discovered pattern as a confirmed finding. Repeated searching can produce apparently striking results by chance.

Further reading: OpenIntro Statistics

4. Communicate uncertainty and reproducibility

A useful notebook explains the question, data, transformations, observations and limitations. Separate data checks from analytical conclusions. Include a few assertions for important invariants, such as unique transaction identities or valid price ranges under stated rules. Keep the workflow runnable from a fresh start so hidden execution order does not alter the result.

For study, use the bundled synthetic retail file or a suitable open dataset. Reconcile totals before and after cleaning, then produce three plots and a managerial note. Explain what action the evidence supports and what remains uncertain. Exploration is valuable when it improves the next question and the reliability of later analysis, rather than simply producing many charts.

Further reading: pandas getting-started tutorials

Study this subject through the nine question words

Who: Who produced and interprets the records?

Whom: Whom does the analysis concern?

Whose: Whose definition controls a metric?

What: What does one row represent?

Where: Where do missing values concentrate?

When: When was the event versus recording time?

Why: Why is a cleaning rule justified?

Which: Which comparison has a valid denominator?

How: How can the notebook be reproduced?

Reconcile transaction grain before exploring revenue

Create a small synthetic table: order 101 has lines for two units at 100 and one at 50; order 102 has one unit at 200; order 103 records a return of one unit at 100 as quantity -1. Add a repeated upload of order 102's line with the same line identifier. Define one row as a transaction line and preserve the raw table. Before removing the repeated upload, signed revenue is 550; after removing that verified duplicate it is 350. The retained table has four lines and three orders. A negative quantity is not a missing value or automatically an error.

Write a transformation log and separate checks for unique line identifiers, distinct order count and the revenue reconciliation. Compare signed revenue with gross positive sales of 450. State which question each answers. Add a missing customer identifier and explain why filling it with zero would invent identity. A notebook should report the actual output produced when run; this exercise does not claim an existing notebook has been executed.

Undergraduates should calculate and reconcile these measures. Postgraduates should examine how duplicate rules and returns alter group comparisons. Research learners should predefine a later confirmatory question and sampling design, keeping hypotheses discovered in exploration separate from tested findings. Recreate the difference between lines, orders and customers without looking at the table.

Study questions and answers

Why should a negative quantity not automatically be deleted?

It may encode a legitimate return or adjustment; the data meaning must determine the cleaning rule.

Extended practice questions

Explain exploratory analysis before prediction using a business transaction table.

Exploratory analysis examines what records mean and how values, missingness, duplicates and unusual patterns appear before making a predictive claim. Identify the row grain, time period and field definitions, then use summaries and visual checks to generate questions. A pattern can reflect a collection rule or data error rather than customer behaviour. Python can support reproducible examination, but analysis decisions must be documented so another person can follow them. Exploration is useful for understanding and hypothesis formation; it does not by itself establish causation or validate a production model.

Marking guide: Grain/meaning; quality/patterns; reproducibility; exploration versus inference. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

Observed values are 10, 20, missing and 30. Calculate the observed-value mean and the result if missing is incorrectly replaced by zero.

The observed sum is 60 across three known values, giving an observed-value mean of 20. If the missing value is replaced by zero, the total remains 60 but the denominator becomes four, giving 15. The difference comes from an assumption, not newly observed information. Missing does not automatically mean zero. State the treatment and investigate why the record is absent; a suitable analysis may retain, exclude or model missingness according to context. A software operation can execute any choice, so correctness depends on the meaning and documented reasoning.

Marking guide: 20 versus15; denominator; missingnotzero; context/documentation. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

Critique deleting every outlier before analysing business data.

An unusual value may be an entry error, a rare valid transaction or evidence of an important process problem. Define the field and investigate the record before excluding it. Preserve the original data and document any correction or exclusion, with sensitivity checks where appropriate. Removing all extremes can conceal risk or misrepresent customer groups. Automated rules can flag candidates, but they cannot independently determine business validity. A defensible analysis explains why a value was handled in a particular way and how that choice affects the conclusion.

Marking guide: Error versus rare-valid; traceability; sensitivity; hidden risk; judgement. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

Design research on reproducible analysis notes and managerial understanding.

Compare equivalent exploratory reports with and without clear data definitions, cleaning decisions and limitations. Measure whether managers can interpret the result, identify assumptions and request relevant follow-up evidence. Record their prior data experience and the problem complexity. Observe whether extensive notes improve understanding or overwhelm the intended reader, and test layered presentation where suitable. The contribution would identify documentation practices that support informed decisions. It should not assume that a reproducible script guarantees valid business meaning or that reported confidence is the same as demonstrated understanding.

Marking guide: Equivalent reports; demonstrated understanding; reader/context; presentation; reproducibility limits. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

An analyst removes all incomplete records and reports a clean average. What must be disclosed and checked?

Record how many rows and which groups were excluded, the missingness definition and the intended analysis population. Complete cases may differ systematically from excluded ones, so a clean numerical result can conceal selection bias. Compare available characteristics and consider an appropriate handling strategy rather than treating deletion as universally correct. Preserve original data and a reproducible transformation. Business owners explain recording context; analysts assess implications. The average describes the retained observations under the stated rule, not automatically the whole business or the cause of observed differences.

Marking guide: Exclusions/groups;selection;handling/reproducibility;retained population;inference limit. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Compare exploratory analysis with confirmatory testing.

Exploration examines records, distributions and possible patterns to understand data and develop questions. Confirmatory analysis evaluates specified claims using an appropriate planned design and method. Finding a striking association while exploring and then treating the same search as an untouched hypothesis test overstates evidence. Record analytical choices, multiple comparisons and limitations. Exploration remains valuable for data quality and hypothesis generation. Managers and researchers should distinguish a pattern worth investigating from a demonstrated effect; software output does not decide which evidential status an analysis has.

Marking guide: Pattern discovery versus planned claim;reuse/search issue;choices/limits;valuable exploration. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Values 10, 20, 30, 40, 100:find mean and median, then remove 100 and compare both summaries.

The full total is200, so mean 200/5=40; sorted middle value is30, so median 30. Removing 100 leaves total 100 across four values, giving mean 25 and median(20+30)/2=25. The changes demonstrate sensitivity to the high observation, not proof that 100 is erroneous or should be discarded. Investigate its source and business context. Report the inclusion rule and counts before comparing results. An outlier may be a real important case, so analytical convenience alone is not an acceptable reason to remove it.

Marking guide: Full 40/30;reduced 25/25;count/rule;outlier not automatic error. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Design a reproducible exploratory notebook for synthetic retail data.

Specify input versions, row grain, units and valid fields. Preserve raw data, document cleaning and retain rejected counts. Inspect duplicates, missingness and distributions before aggregating, and compare relevant groups with denominators visible. Separate observations, hypotheses and causal claims in the narrative. Provide independently checkable small examples and instructions for rerunning from a clean environment. A notebook supports traceability but can still contain hidden execution-order errors. Business users validate definitions, and reviewers should check the full sequence rather than trust a polished chart produced from an undocumented intermediate state.

Marking guide: Version/raw/cleaning;quality and groups;claim boundaries;clean rerun;hidden state. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Revision cards

Explain exploratory analysis before prediction using a business transaction table.

Explore definitions, grain, missingness and patterns before prediction; summaries generate questions but do not establish causation.

An analyst removes all incomplete records and reports a clean average. What must be disclosed and checked?

Disclose exclusions and compare retained versus missing cases. A complete-case average may not represent the intended business population.

Compare exploratory analysis with confirmatory testing.

Exploration generates understanding and hypotheses;confirmation tests specified claims. A discovered pattern is not automatically independent confirmatory evidence.

Values 10, 20, 30, 40, 100:find mean and median, then remove 100 and compare both summaries.

Full mean 40, median 30; without 100 both 25. A large value's influence does not establish that it is invalid.

Design a reproducible exploratory notebook for synthetic retail data.

Preserve inputs, document transformations and rerun in a clean sequence. Label observations and hypotheses rather than treating charts as causal proof.

Observed values are 10, 20, missing and 30. Calculate the observed-value mean and the result if missing is incorrectly replaced by zero.

Observed-value mean is 20; zero replacement gives 15 by assumption. Missing values are not automatically zero.

Why distinguish exploration from confirmation in data analysis?

Exploration generates questions and notices patterns; confirmation evaluates a stated claim using an appropriate design. Reusing the same evidence after searching many patterns can exaggerate certainty. Record the exploratory choices and seek suitable validation.

Practice task

Analyse the bundled retail data in Python. Document grain, duplicates, returns and missingness; reconcile totals and write one recommendation with two limitations.

Sources and further reading

  • pandas getting-started tutorials
    Type: Free official tutorials
    Use: Tabular input/output, selection, summaries, joins and time series
  • Harvard CS50 Python
    Type: Free OpenCourseWare; submission accounts and paid certificate options differ
    Use: Functions, files, exceptions, tests and objects
  • OpenIntro Statistics
    Type: Free digital learning resources; printed books and optional payments separate
    Use: Sampling, probability, inference and regression

Open interactive reading and progress tools