After I had signed up, I configured to download some data. This was the total annualized quarterly GDP as well as the goods and services components, see the picture below which is a screen shot of data from the FRED system.
The download was a text file, it had a header row and was delimited by tabs. This is not ideal, but it is something that the csv Python standard library can handle. The idea was to use matplotlib to graph the data. I could have tried to create the graph on a Tkinter canvas using the draw functions. But I am getting ahead of myself...
First we need to read the data and create Lists for the x and y values of the two different lines. I will run through the code I wrote. First we need to open the text file:
file = open(filelocation, newline='')
r = csv.reader(file,delimiter='\t')
Then I will initialize variables:
period=[]
goods=[]
services=[]
header=True
The variable header is there so that we can skip over the header row during the loop which reads the data and creates the iterables that will be used to graph the data. The Pyplot api expects NumPy arrays for the data to be graphed but Lists and most other iterables work.
for row in r:
if header:
header=False
else:
date=row[0]
serv=float(row[1])
good=float(row[2])
total=serv+good
dateval=float(date[0:4])+float(date[5:7])/12
period.append(dateval)
goods.append(good/total*100)
services.append(serv/total*100)
Now at the start I had imported matplotlib.pyplot as plt, and the next part of the code creates the graph and shows it using rather simple matplotlib calls. I did look up a lot of stuff on this in the examples and tutorials, but it is not very clear so I struggled a bit to get it to work right.
fig,ax = plt.subplots()
line1, = ax.plot(period,goods,label='Goods')
line2, = ax.plot(period,services,label='Services')
ax.legend(loc='upper left')
ax.set_title('Change in GDP composition over time')
plt.ylabel('% of GDP')
plt.xlabel('Year')
plt.show()
Here's the final product:
What does this mean?
In this graph we see a long-terms trend wherein the American economy has been more and more reliant on services instead of goods. We don't make things any more, or maybe a better way to put it, we make things with such high efficiency and productivity that to feed, house, cloth, provide transport and other utilities, some one third of us can provide for everyone. So we have to find something for the other 2/3rds to do. That turns out to be providing any and all kinds of services to the general population. This trend has been around for a while and it probably extends to the left back to the turn of the century although likely it flattens out. During that time, many have treated it like the weather: something to complain about, but nothing can be done about it. Even the current politicians are not going to be able to reverse this trend no matter how hard they try. About the only possible strategy would be to do everything to limit or even reverse the growth in population. However, this would have other significant adverse consequences, putting the economy into a depression.One take-away is that if you are starting a new business, concentrate on services rather than goods. If you have a goods-related business, then consider adding some kind of service provision to complement what you make. Growth in Services is much more likely, if not easier.
No comments:
Post a Comment