University of Adelaide · FACULTY OF BUSINESS ANALYTICS

BUSI2001 Chap.2 Python Fundamentals for Data Analysis

- one subject, every graph, every model, every mark
8 Chapters6-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 2 of 10 · BUSI2001

Python Fundamentals for Data Analysis

Python turns business formulas into reusable steps. This chapter covers the workshop's foundations on Google Colab: data types and explicit conversions, operators for profit and return on investment, if and elif logic, for and while loops for growth projections, and functions that package a rule.

It then follows the extract, transform and load sequence on an airline file, encodes categories with label, binary and one-hot methods, and reads correlation and simple regression. The chapter's worked example fits a line to five weeks of advertising and sales by hand and explains why a significant p-value is neither proof of cause nor proof that an effect is large enough to matter to the business.

By the end, Python output should read as a set of claims you can check line by line rather than a block of code you hope is right.

In this chapter

What this chapter covers

  • 01

    Data types and conversion

  • 02

    Operators and Boolean tests

  • 03

    Loops for projections

  • 04

    Functions and modules

  • 05

    Extract, transform, load

  • 06

    Label and one-hot encoding

  • 07

    Correlation bands

  • 08

    Regression slope and p-value

Worked example · free

Fitting a sales line to five weeks of advertising spend

Q [5 marks]. Weekly advertising spend x is 1, 2, 3, 4 and 5 thousand dollars and weekly sales y are 12, 15, 16, 19 and 23 thousand. Fit y = a + bx, calculate r and forecast sales at a spend of 6. The marks shown are an AskSia revision weighting, not a University marking scheme.
Advertising and sales with a fitted lineFive points of weekly advertising and sales with the fitted line y equals 9.2 plus 2.6x and a hollow forecast point at six.1234561020Weekly ad spend ($000)Weekly sales ($000)ŷ=9.2+2.6x
Each filled dot is one week of advertising spend and sales, the orange line is the fitted equation, and the hollow dot shows the forecast of 24.8 at a spend of six.
  • +1Find the means: x averages 3 and y averages 17.
  • +1Sum the cross-products of deviations to get 26 and the squared x deviations to get 10.
  • +1Slope b = 26 / 10 = 2.6 and intercept a = 17 - 2.6 x 3 = 9.2.
  • +1With squared y deviations of 70, r = 26 / the square root of 700 = 0.98, a strong positive relationship.
  • +1Forecast at x = 6: 9.2 + 2.6 x 6 = 24.8 thousand dollars, just beyond the observed range.
The fitted line is y = 9.2 + 2.6x with r = 0.98, and the forecast at a spend of six thousand is 24.8 thousand dollars of sales.
Sia tip — Report the slope in the units of the data: 2.6 thousand dollars of sales per extra thousand of advertising, within the observed range.
Glossary

Key terms

Data type
The category Python assigns to a value, such as string, integer, float or Boolean, which decides how it behaves.
Label encoding
Replacing ordered categories with integers that preserve their ranking, such as 0 to 3 for Low to Critical.
Regression slope
The average change in the outcome for a one-unit increase in the input variable.
Confounder
A third variable that influences both variables in a relationship and can create a misleading association.
Google Colab
A free cloud-based notebook environment for writing and running Python code in a browser.
Augmented operator
A shorthand such as += that updates a variable using its current value in one step.
FAQ

Python Fundamentals for Data Analysis FAQ

Why does int(0.75) return zero?

Converting a float to an integer in Python drops the decimal part rather than rounding, so 0.75 becomes 0 and 2.9 becomes 2. This matters when rates are stored as fractions. Use round() when rounding is intended, and check the type of any suspicious value before it reaches a calculation.

When should I use one-hot rather than label encoding?

Use label encoding only when the categories have a natural order, such as Low, Medium, High and Critical priority. For nominal categories such as product sub-categories, one-hot encoding creates a separate 0 or 1 column for each level, so a model cannot read a false ranking or equal spacing into the codes.

Does a p-value below 0.05 mean the effect is important?

No. It means the relationship is statistically significant at that level, not that it is large, useful or causal. The course warns that significance often morphs into importance in people's minds. Judge importance by the size of the slope in business units and by context, and look for confounders before claiming cause.

Why does a while loop sometimes never stop?

A while loop repeats until its condition becomes false, so if nothing inside the loop moves the value towards that point, it runs forever. In the revenue-doubling exercise, forgetting to multiply revenue by the growth rate inside the loop would keep the condition true. Always update the tested variable on every pass.

Study strategy

Assessment move

Work in a Colab notebook alongside this chapter. Type each basic exercise yourself before asking an AI assistant for help, so you can tell when its code differs from your intent: assign the four company variables, convert the three values, compute profit and ROI, and write the if-elif discount rule with thresholds in descending order.

Run the five-year investment loop and the doubling loop, printing inside each iteration so you see the values change, and confirm the five-year result with the compound formula. For ETL, prompt for each stage separately and check the output after each one: the data types after extraction, the converted distance after transformation, and the row count after filtering.

For encoding, write down which columns are ordinal and which are nominal before choosing a method. Finally, compute one small regression by hand, as in the worked example, so that software output becomes something you can read critically rather than accept. Keep a personal cheat list of the three conversions, the two loop types and the encoding rules, written in your own words with one example each.

Revisit the regression page after the machine learning topic, because logistic regression extends the same idea of weighting inputs to predict an outcome.

Working through Python Fundamentals for Data Analysis in BUSI2001? Sia is AskSia’s AI Business Analytics tutor — ask any BUSI2001 Python Fundamentals for Data Analysis question and get a clear, step-by-step explanation grounded in how BUSI2001 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 25 of your University of Adelaide subjects - and 1,000+ Bibles across every Australian university.
Sia - your BUSI2001 tutor, unlimited, worked the way the exam marks it
The full 6-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works
BUSI2001 · Emerging Technologies, Data and Business Analytics - independent study guide on the AskSia Library. More University of Adelaide subjects · Microeconomics across all universities