This code computes the distribution of mileage of private cars in Switzerland in 2015, based on the data of the Transport and Mobility Microcensus (MTMC, www.are.admin.ch/mtmc). As an example, 70% of private cars with the lowest mileage in the last 12 months travel 42% of the total mileage of private cars. This code generates a figure (available in French, German and English) presenting the results and the results as a CSV-file containing the cumulative proportion of total mileage for each group of 10% of the vehicles (in increasing order of mileage).
The sample basis is similar to the one used in figure G 3.3.2.3 in the main report of the MTMC (p.31, in French and in German). It is slightly higher here than in the main report, because we don't decompose the mileage between "in Switzerland" and "abroad". Consequently, we don't remove observations without this information.
The figure has been published on Mastodon in French, German and English and on Linkedin in English.
These instructions will get you a copy of the project up and running on your local machine for reproducing the result and understanding how it has been generated.
To run the code itself, you need python 3, pandas, numpy, matplotlib and seaborn.
For it to produce the results, you also need the raw data of the Transport and Mobility Microcensus 2015, not included on GitHub. These data are individual data and therefore not open. You can however get them by filling in this form in German, French or Italian. The cost of the data is available in the document "Mikrozensus Mobilität und Verkehr 2015: Mögliche Zusatzauswertungen"/"Microrecensement mobilité et transports 2015: Analyses supplémentaires possibles".
Please copy the file fahrzeuge.csv that you receive from the Federal Statistical Office in the folder "data/input". Then run run_car_mileage_in_Switzerland_in_2015.py.
DO NOT commit or share in any way the CSV-file fahrzeuge.csv! These are personal data.