Categorical (qualitative) variables take non-numerical values.
Quantitative (numerical) variables take number values. Furthermore, quantitative variables are divided into:
—Continuous variables, which can take any numeric value (to any degree of precision) in some range (e.g. any value between 0 and 1),
—Discrete variables, which are not continuous on any range (e.g. a variable that takes the integer values from 0 to 100).
Histograms work well for discrete variables. To display the frequency of continuous variables, we need something else.
One approach for visualizing the distribution of continuous variables is to divide the set of possible values into intervals and count the number of values in each interval.
When plotting a histogram in pandas, you can set the number of intervals (bins) and explicitly set their boundaries:
data.hist(bins=[value1, value2, value3, value4, ..., valueN])
Always remember, though, that the success of this approach depends on carefully choosing good interval bounds - a task that can be difficult even for experienced data analysts.
To overcome the difficulties of creating a histogram for a continuous variable, we can use a slightly different (but still similar) technique that represents frequency not as the height of a column but as the area of that column. You can find the area of a column the same way you find the area of a rectangle: the length of the interval times the height of the column. This area is the relative frequency, or frequency density, of the continuous variable. A histogram that uses frequency density is called a density histogram.
To estimate how many values fall in any interval (not just one that was used to plot the histogram), take two values and find the total area of the density histograms between them. The number you get will be an estimate for the number of values falling in the interval.
We can also display the frequency for continuous variables by using continuous lines to represent the values' frequency, and then take the total area under the curve to get the likelihood of a value falling into a given interval.
We can use location metrics, like the median and mean, to estimate approximately where a data set is located on the numerical axis.
The mean and median are more formally called the algebraic metric of location and the structural metric of location, respectively.
Location metrics are not enough if you want to understand the data, since most data points will not be located right at the average value. Thus, you also need to know how the data is scattered around these measures.