+91 81900 98289

Data Distribution

This Data Distribution lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.

A distribution is the pattern of how often each value appears. Counting bins is the simplest picture of that pattern.

A flat count means the values are spread out. A tall bin means many rows landed in one range.

Example 1: Start here

Look at the bins before you pick a model. A skewed pile of scores is not a straight line.

scores = [61, 64, 72, 75, 81, 90, 92] # a list; the values stay in this order bins = {} # a dictionary; each key has one value for score in scores: # repeat the indented lines once per value bucket = (score // 10) * 10 # a tuple; a fixed group of values bins[bucket] = bins.get(bucket, 0) + 1 # change this one field print(dict(sorted(bins.items()))) # a new list, sorted

Example 2: Add two rows

Data Distribution applies one operation to every number. zip pairs the rows, and the list keeps each sum.

left = [1, 2, 15] # a list; the values stay in this order right = [10, 20, 30] # a list; the values stay in this order print([a + b for a, b in zip(left, right)]) # pair the lists, then combine each pair

Example 3: Average a column

The average is the total divided by how many numbers you have. That is the same summary a statistics page starts with.

scores = [70, 15, 90] # a list; the values stay in this order print(sum(scores) / len(scores)) # len counts the items

Example 4: Keep values above a line

A cutoff drops the low values. Change 80 and run the example again to see who remains.

scores = [70, 15, 90] # a list; the values stay in this order print([score for score in scores if score >= 80]) # keep the items that pass the test
Look at the bins before you pick a model. A skewed pile of scores is not a straight line.
Call Now 81900 98289