Vehicle Manufacture Comparison

Pengtong Yang
INST414: Data Science Techniques
3 min readFeb 11, 2022

As I browsed and skim through the vehicle API that I found interested in, which provided data for many aspects about vehicles. There are multiple vehicles made by USA, Japan , Germany and other countries combined. With several vehicle types that I haven’t heard of. I wanted to find out the most manufacture made by country, by vehicle types.

The data that I collected from The API are specific data for country list, vehicle type list, and manufacture ID. By comparing country list and vehicle type list will provided a initial idea of where different types of vehicle made from. Manufacture ID provided as a proof of vehicle and manufacture country.

Libraries used: time, json, request. matplotlib.pyplot, seaborn, pandas, and ast.

Theme used: darkgrid

I retrieved data from the API, more specifically from the API to Get All Manufacturers using request. Get assign into Json file and named resp. Test with resp.staus_code. And determine the file type using resp.headers[‘content-type’]. Assigned resp.content to json file and named response. The retrieving data step had succeed at this point.

The next step is converting the data into usable file which is the python file. By converting response into python file named python_file using json.loads. Retrieved only the subset of python_file which is the “Results” subset. Rename python_file to python_file1. Next, converting python_file1 into datafram using pd.DatFrame and named df1. I also rename all the column tiles as some of the title are not easy to understand, which I used df.columns[‘name,’]. At this point all the data are ready for making visualized graphs.

  1. The scatterplot from seaborn: assign VehicleTypes to X, and Country to Y.
Graph 1: Scatterplot for Vehicle Types in different Countries

2. The scatterplot from seaborn: assign Manufacture_ID to X, and country to Y.

Graph 2:Scatterplot for Manufacture ID for different Countries

3. The bar graph: dispot from seaboard which I assign country for Y, and set stat to count.

Graph 3: Bar graph(displot) for most vehicle count for different Countries

Example of bugs that I encountered: 1. Data for vehicle types are in lists instead of word. The data cannot be used right away after retrieved from API. First I tried using split the list using pandas split to separate the list, but had encountered errors. I fingered that the list contained courtly bracket and squared brackets. Next, I had to perform manipulation for the data using pandas series split. I was able to split the vehicle types and drop the unneeded columns that contain unnecessary data. 2. This bug was much easier than the first one, as display bar graph for density for vehicles made by different countries. The country names are overlapped. The way I fixed the graph is by turning the graph horizontally. As shown in the graph 3.

As you can see on graph 1, 2 and 3 combined. They provided enough data information for the most of each type of vehicle made by country, and by manufacture ID. The most vehicles were made by United States in graph 3, with supported data in graph 1 that United States had the most vehicle types, and supported data in graph 2 that United states also had the most manufacture ID numbers in variety.

--

--