Business Analytics Exam #2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/139

encourage image

There's no tags or description

Looks like no tags are added yet.

140 Terms

1
New cards

What does it mean to iterate?

To go through the values one at a time

2
New cards

When is for used?

When the number of passes is known (one per row, per item, per file)

3
New cards

The rule with for

The collection says when to stop

4
New cards

How does for work?

for <var> in body>: If there’s any values left in the sequence, assign the next value in <sequence> to <var> and execute the body, then loop back again

5
New cards

What is the sequence in a for code?

What you are going through

6
New cards

<var>

A name you invent. Nothing is special about it.

7
New cards

What does the indented block tell Python in loops?

which lines to repeat (four spaces)

8
New cards

range()

Looping a fixed number of times

9
New cards

list(range(5))

starts at 0, stop before 5 (0, 1, 2, 3, 4)

10
New cards

list(range(1,6))

starts at 1, stops before 6 (1, 2, 3, 4, 5)

11
New cards

list(range(0,10,2))

Every second number up to but not including 10 (0, 2, 4, 6, 8)

12
New cards

len(range(1,6))

How many passes occurred (5)

13
New cards

Where do you place print in loops?

Outside of the indent. That way, it only runs once.

14
New cards

What happens if you place print inside of the indent?

It runs every pass

15
New cards

Accumulator

Name that collects results across all passes. You set it up before the loop and change it inside of the loop.

16
New cards

How is if -> elif -> else tested?

Top to bottom

17
New cards

Where does if -> elif -> else stop?

The first line. Everything below is skipped even if also true

18
New cards

In if -> elif -> else loops, you should put what condition first?

The narrowest

19
New cards

True or false: An inside loop asks its question once per value, and only values that pass get acted on

True

20
New cards

With dictionaries and loops, what should you be mindful of?

Differentiating between values and keys (example: for k, v in price.items() keeps keys and values together)

21
New cards

What happens if you run for k in price

You get keys only as an answer

22
New cards

Building a list using loops

list = [] outside of the loop. At the end of the loop mention list.append(r), with r being "for r in data"

23
New cards

Enumerate

Hands you the position with value (ex: sales = 46, 54, 92. For value in enumerate(sales): print(value) gives (0, 46) (1, 54) (2, 92))

24
New cards

While

The number of passes is not known - repeats until something is true

25
New cards

Rule with while

You must change the condition inside, or it never ends

26
New cards

How does while work?

while <condition>: if <condition> evaluates to true, execute <body> and then loop back.

27
New cards

What must you have in while loops?

A false scenario (ex: x = 5, while x > 0, x = x - 1)

28
New cards

"How long until we double?" is a question answered with what loop?

While (we don't know the answer!)

29
New cards

Parts of a while loop

Something set up before (balance), a condition (balance < 200000), a line inside that moves the condition towards false

30
New cards

Break

Stops the loop entirely, right there

31
New cards

When are breaks used?

When you found out what you came for and the rest doesn't matter

32
New cards

Continue

Skips the rest of this pass and moves to the next value. The loop keeps running.

33
New cards

Nested Loops

The inner loop runs all the way through, once for every pass of the outer one

34
New cards

IndentationError with Loops

Body not indented

35
New cards

NameError with Loops

Accumulator was never started (ex: total = total + r with no total = 0 before the loop)

36
New cards

IndexError with Loops

Last pass asks for a position that isn't there

37
New cards

ValueError with loops

Doesn't specify .items() in dictionary loops

38
New cards

Business Analytics Process

Question/Problem, Data Collection, Processing/Cleaning, Analytics Methods, Decision

39
New cards

Business Analytics

Process of transforming data into actionable insights by identifying meaningful trends, making predictions, and other techniques

40
New cards

Levels of Qualitative Data

Nominal and Ordinal

41
New cards

Nominal Data

Names (may compute counts, mode, shares)

42
New cards

Ordinal Data

Names with order (may compute counts, mode, median)

43
New cards

Levels of Quantitative Data

Discrete and Continuous

44
New cards

Discrete Data

Whole Numbers

45
New cards

Continuous Data

Numbers with Decimals

46
New cards

Types of Continuous Data

Interval and Ratio

47
New cards

Interval Data

No true zero

48
New cards

Ratio Data

True Zero

49
New cards

Time-Series Data

Data collected over many time periods

50
New cards

Cross-Sectional Data

Data collected from several entities at the same time

51
New cards

Name the skew: mean < median < mode

Negative/Left Skewed

52
New cards

Name the skew: mean = median = mode

Normal Distribution

53
New cards

Name the skew: mode < median < mean

Positive/Right skewed

54
New cards

What method of central tendency should you quote in positive/negative skews?

Median

55
New cards

What method of central tendency should you quote in normal distribution?

Mean

56
New cards

Methods of dispersion

Range, variance, standard deviation

57
New cards

The larger the spread, the (larger/smaller) the dispersion

larger

58
New cards

What happens when standard deviation = 0?

Every value is identical

59
New cards

df.info()

Gives non-null counts, data types, shape

60
New cards

df.describe()

Gives count, mean, standard deviation, minimum, quantiles, maximum (numeric columns only)

61
New cards

df["amount"].quantile(0.25)

A quarter of the data is below this number

62
New cards

df["amount"].quantile(0.75)

A quarter of the data is above this number

63
New cards

Which descriptive statistics are not resistance to "bad rows"/outliers?

Mean, standard deviation

64
New cards

Which descriptive statistics are resistant to "bad rows"/outliers?

Median, IQR

65
New cards

df["names"].value_counts()

How many of each value there are

66
New cards

df.groupby("names")["amount"].mean()

Mean of amount per name in names

67
New cards

df.kurt()

How much lives out in the tails

68
New cards

df["names"].nunique()

How many distinct values there are

69
New cards

df.iloc[3]

Gives 3rd index row information

70
New cards

Difference between iloc and loc

iloc doesn't survive a sort while loc does

71
New cards

df.iloc[-1]

Gives last row information

72
New cards

df.iloc[3,2]

Gives one cell by two positions (can also use position, column name)

73
New cards

df.sort_values("value")

Sorts by smallest first (ascending=False reverses this)

74
New cards

df.sort_index()

Back to index order

75
New cards

Primary sources

First-hand gathered data (interviews, surveys, experiments, observations)

76
New cards

Secondary Sources

Collected by others (government data sources, journals, public websites)

77
New cards

4 Dimensions of Data Quality

Accuracy, Completeness, Consistency, Usability

78
New cards

Questions to ask about data

Who collected/produced it? When was the data collected? What was their intent? is it a reputable source?

79
New cards

What happens if you have biased data?

Get new data

80
New cards

What happens if you have outliers?

Exclude, include, or investigate

81
New cards

What happens if you have invalid data?

Fix or remove

82
New cards

What happens if you have missing data?

Drop rows/columns or replace (with mean, median)

83
New cards

What happens if you have duplicates?

Remove by .drop_duplicates()

84
New cards

What happens if you have stale data?

Be cautious with results

85
New cards

What happens if you have inconsistency?

Remove or fix by str.strip(), str.title(), converting dates

86
New cards

Data Cleaning Process Steps

Copy original data, look using info, strip symbols, convert types, drop duplicates, handle blanks, look again

87
New cards

df.shape()

Gives rows and columns as a tuple

88
New cards

df.isna().sum()

How many blanks are there?

89
New cards

df.duplicated().sum()

How many duplicates are there?

90
New cards

df['names'].nunique()

How many distinct spellings are there?

91
New cards

list(df['names'].unique())

What are the distinct spellings in the column 'names'?

92
New cards

copy = df.copy()

Creates a copy of the original dataset

93
New cards

df["column"].astype(float/int/str)

Fixes data types

94
New cards

df['pop'] = df['pop'].fillna("value")

Fills values with "value"

95
New cards

df = df.dropna(axis = 0, how = 'all')

Drops a row (to drop a column, change axis to 1)

96
New cards

df[df.duplicated()]

Point out duplicated rows

97
New cards

df["amount"] = pd.to_numeric(df["amount"], errors ="coerce")

Use if there's data issues while you're trying to convert data types (ex: there's a variable named "pending amongst a sea of numbers). Makes the variable nan.

98
New cards

iqr = df["pop"].quantile(0.75) - df["pop].quantile(0.25)

Finding IQR

99
New cards

max = df["pop"].quantile(0.25) - iqr and min = df["pop"].quantile(0.75) + iqr

Finding the maximum and minimum values

100
New cards

(df[df["pop"] < min]) | (df["pop"] > max)])

Finding outliers