AOKI's copy&paste archive

高専から駅弁大学から東工大を経て大企業へ 浅く広い趣味とかキャリアの日記を

Comparing data by python

objective

I want to check a difference between measured and estimated by MLIT(: Ministry of Land, Infrastructure, Transport and Tourism) in seminar as part of research in university.
Data mean the number of medium and large size category tracks include trailers in Japan.

Honestly, Excel is easily and simply.
I want to write smarter code but anaconda(python software) continued to output errors :(
Thus I decide writing simply as possible as I can.

code

# -*- coding: utf-8 -*-
"""
Created on Sat Jan 25 17:08:42 2020

@author: aoki
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#%%

jikenkyo = pd.read_excel('nums.xlsx')
mlit = pd.read_excel('MLITest.xlsx')
#reforme
jikenkyo.heisei = jikenkyo.heisei+1988
mlit = np.transpose(mlit)

jikenkyo = jikenkyo.loc[:,['heisei','ICE']]
jikenkyo = jikenkyo.drop(0)

mlit = mlit.drop(['year','Unnamed: 1'])
mlitmiddle = (mlit[4].astype(float)+mlit[5].astype(float))*10**5
mlitall = (mlit[8].astype(float))*10**5

plt.plot(jikenkyo.heisei,jikenkyo.ICE,label='measured')
plt.plot(mlit.index,mlitmiddle,label='MLIT estimate: over middle')
plt.plot(mlit.index,mlitall,label='MLIT estimate: all')
plt.legend()
plt.ylabel('number of freight vehicles')
plt.ylim(0,)
plt.xlabel('time /year')
plt.show()

output

f:id:pytho:20200126164021p:plain
A difference is larger than I think.

considerlation

This is difference of category in each survey or statics maybe.
I'll check it.