Skip to content
Save the video (4.2 MB)
Open the course

Lessons ·

Visualizing and exploring

Histogram, box plot, scatter plot and correlation: make Awa's sales speak.

Transcript

For twelve days, Awa noted her customers, her sales and the rain. Faced with these columns of figures, she doesn't see much. A chart, however, can show in one second what the table hides. For this, she uses seaborn, a chart library. First look at this journal on the right: one row per day, and three columns.

The histogram sorts the days into four ranges of sales, and the height of each bar says how many days are in it. We see at once that most days are in the first two ranges, and that a single day is far to the right, a long way from the others. In the code, data gives the table, x the column to study, and bins the number of ranges.

And how can we clearly see this isolated day? With a boxplot, also called a box-and-whisker plot. The box holds half of the days, and the line inside marks the median. Here, it is 23,500 francs: half of the days sold less, and the other half more. The whiskers reach out towards the other days, and the isolated point is an outlier, in other words a value very far from the others: here, 60,000 francs.

A chart does not say why. Awa must check: is it a typing mistake, or a real festive day? Here, she had far more customers that day, so she keeps this row.

And to see whether two columns are linked? We use a scatter plot: each day becomes a point, placed according to its customers and its sales. Here, the points rise together: the more customers there are, the higher the sales. The point at the very top right is our exceptional day.

Correlation measures this link with a single number, between minus 1 and 1. Close to 1, as here, the two columns rise together. Close to zero, they have no straight-line link. Here, it is 0.98, which is very close to 1.

The corr method calculates the correlation of each column with each of the others, and heatmap colors the result. Customers and sales are closely linked. The cell where they cross is 0.98. On the diagonal, each column is 1 with itself, which is normal. Rain tends to go the other way: the number is negative, so when it rains, there are fewer customers.

So customers cause sales, and rain drives customers away? It is possible, but this table does not prove it. Two columns can move together because a third one pushes them both, like a market day. We must always look for another explanation before concluding.

In the lesson, draw these charts on real data, then write your conclusions in a few sentences. Try without watching the video again.

Voices: Google Chirp 3 HD (Despina, Enceladus).

Photos : One Idea LLC, StockSnap, CC0