Extract Column from Tables
Contents
Problem description
I have some census data, which are 20 excel files for 20 year respectively (1980 - 1999). Each of the files contains county names and corresponding census data, e.g., GRDP, population, education.
The aim is to get GDP data from each year, and save them in one excel file.
I used Python 3.7 pandas packge to solve this problem.
Code
Function 1: get GPD column from a excel file
1 | # get GRDP and name from a certain year |
Function 2: join a column to an existing table
1 | # join a table to the table of 1999 |
Global variable
1 | # initialize |
Add all the GPD column to the global variable
1 | for i in range(1998, 1980, -1): |