Python – Statsmodels Example – Video

Statsmodels is a nice statistics library in Python, which eases the data processing and analysis with Python. The library is available here – statsmodels.org and on its official web site the installation guide is always up to date.

In the live coding video, the following points are mentioned:

Imporing libraries and loading macrodata dataset to pandas is the standard start.

Displaying data from dataset in all columns and all rows is actually a 1-liner. 1 per column, 1 per row:

Inserting the index to the data is a standard trick, which could be carried out through different ways – e.g. via length or via from-to period:


Plotting the data with matplotlib is the interesting part. In general, this is why pandas and jupyter are powerful – the display of the data is quite fast – just a single df.plot() starts the magic.


Getting the trend and the cycile of the dataset with  hp_filter.hpfilter is actually parsing data from a tuple to the dataset:


Presenting the data, zooming to specific dates is actually pretty interesting, if you have mastered the list slicing notations.


Tagged with: , ,