How it works...

The first argument is the only argument required for the concat function and it must be a sequence of pandas objects, typically a list or dictionary of DataFrames or Series. By default, all these objects will be stacked vertically one on top of the other. In this recipe, only two DataFrames are concatenated, but any number of pandas objects work. When we were concatenating vertically, the DataFrames align by their column names.

In this dataset, all the column names were the same so each column in the 2017 data lined up precisely under the same column name in the 2016 data. However, when they were concatenated horizontally, as in step 4, only two of the index labels matched from both years--AAPL and TSLA. Therefore, these ticker symbols had no missing values for either year. There are two types of alignment possible using concat, outer (the default) and inner referred to by the join parameter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset