How to Analyze Car Listing Data: Price and Mileage

Published:

11 minute read

Acar Diveroli
Written by: Acar Diveroli
Car listing cards rise to price height and sink with mileage; a blue curve traces the drop, duplicate ads set apart as DUP

Car listing data analysis means reading the market from the make, model, year, mileage and price fields of used-car ads. Raw listings do not go straight into analysis. The same model arrives in three spellings, and mileage comes as text like "120.000 km". The same car is also listed several times. Skip these steps and the averages drift without warning. This post covers the fields you need, normalization, removing duplicate listings and the relationship between age, mileage and price.

The listing fields you need

Ten fields are enough to read the market. Each field looks different in its raw form and in the form used for analysis.

FieldRaw exampleForm used in analysis
Make, modelRENAULT, Clio Vrenault, clio
Trimtouch touch
Year2019Integer, plus age
Mileage120.000 km120000
Fuel, gearboxBenzin, ManuelFixed category list
CityİstanbulOne spelling
Price1.050.000 TL1050000
Listing date2026-11-20Date type

Keep the listing ID too. It does not go into the analysis, but you need it to track relisted cars and price changes.

Where you get the data is a decision that comes before cleaning. The first choice is the listing site's official API or a data partnership. The fields then arrive structured, and half of the normalization work disappears. If you read public pages, follow the site's terms and its robots.txt file, and keep the request rate low.

Model and trim names

The same car shows up in a listing under several spellings. The seller writes Clio, CLIO, Clio V or Clio 5. A trailing space stays at the end of the trim name. These become separate rows when you group, and each group looks smaller than it really is.

The fix takes two steps: clean up case and whitespace, then apply a mapping dictionary. In the code, raw is the DataFrame that holds the listings.

python
import numpy as np
import pandas as pd

df = raw.copy()
for col in ["make", "model", "trim"]:
    df[col] = df[col].str.strip().str.lower()

model_map = {"clio v": "clio", "clio 5": "clio"}
df["model"] = df["model"].replace(model_map)

Maintain the mapping dictionary by hand and grow it over time. Fuzzy matching, which merges similar names automatically, can also merge different body styles or generations. If the generation affects price, add a separate generation column instead of folding it into clio.

Turkish letters hide a trap. In Python, "İstanbul".lower() does not return istanbul. Turkish has a dotted capital İ next to the dotless I, and Python's lower() does not follow Turkish casing rules. The capital İ becomes a lowercase i plus a combining dot mark, and the string grows to nine characters. In our test this value was not equal to "istanbul". Don't lowercase the city column; map it against a fixed list of cities.

From text to numbers

Mileage and price are text on the page: 120.000 km, 1.050.000 TL. In Turkish notation the dot is the thousands separator. That is why float("120.000") returns 120, not one hundred twenty thousand. The safest way is to delete every character that is not a digit.

python
for col in ["km", "price"]:
    df[col] = (df[col].str.replace(r"\D", "", regex=True)
               .replace("", pd.NA).astype("Int64"))

df["listed_at"] = pd.to_datetime(df["listed_at"])

An empty cell becomes pd.NA and the row is kept. Int64 is an integer type that can hold missing values.

The blind spot of this method is the unit. A seller who writes 120 bin km (Turkish for "120 thousand km") ends up with the value 120. Check the range after the conversion. Rows older than one year with mileage under 1,000, or prices ten times cheaper than the model's market, go to a list for manual review.

Removing duplicate listings

When the same car is listed again, it usually gets a new listing ID. So the ID does not catch duplicates. You need to build a key from the fields that describe the car.

python
df["km_band"] = df["km"] // 5000 * 5000
key = ["make", "model", "trim", "year", "km_band", "city"]
df = (df.sort_values("listed_at")
        .drop_duplicates(subset=key, keep="last"))

The mileage band tolerates a seller nudging the mileage up a little when renewing the ad. Sorting by date and passing keep="last" keeps the car's latest price. In our sample table, the same Istanbul car appeared on November 2 and November 20 under two IDs. Ten rows came down to nine unique cars, and the price from the second listing was kept.

The key has two weak spots. Two values on either side of a band edge, such as 119,900 and 120,100, fall into different bands. In the other direction, two identically equipped cars at the same dealer collapse into one record. If you have color or a seller ID, add them to the key. Before deleting, also write the first listing date to a separate column. Time on market and price cuts come from that column.

Age, mileage and price

Age and mileage push the price down together. Put both in the same model and you see the share of each one separately. The code below fits the line price = a + b × age + c × km with the least squares method.

The table we ran the code on is a sample: we wrote the ten rows by hand, and they are not real listings. The numbers show the method and say nothing about the market.

python
df["age"] = 2026 - df["year"]
X = np.column_stack([np.ones(len(df)), df["age"], df["km"]]).astype(float)
y = df["price"].astype(float)
a, b, c = np.linalg.lstsq(X, y, rcond=None)[0]

c_km_only = np.polyfit(df["km"].astype(float), y, 1)[0]
print(f"Age-km correlation: {df['age'].corr(df['km'].astype(float)):.2f}")

Output on the sample table:

MeasureResult
Per year of age (two-variable model)−83,138 TL
Per 10,000 km (two-variable model)−698 TL
Per 10,000 km (mileage only)−27,837 TL
Age-mileage correlation0.99

The trap is in this table. A line fitted on mileage alone loads the effect of age onto mileage as well. That is why the loss per kilometer comes out large. In our sample table, age and mileage rose almost in lockstep, so even the two-variable model could not separate them. The share of mileage stayed close to zero.

In real data this relationship is looser, but still strong. If you want to measure depreciation per kilometer, look within a single model year. In one year's listings age is constant, and the slope shows mileage alone. If the group does not have at least a few dozen listings, don't publish the result.

City and country differences

Measuring the price gap between cities with the raw median is misleading. If one city sells newer cars, its median comes out higher, but the cars are not the same. The right measure is the deviation from the model's prediction (the residual).

python
df["residual"] = y - X @ np.array([a, b, c])
print(df.groupby("city")
        .agg(median=("price", "median"), residual=("residual", "mean"))
        .round(0))

In our sample table, the Istanbul median came out 122,500 TL higher than Ankara's. With the effect of age and mileage removed, the gap fell to about 1,800 TL. Almost all of the difference came from the Istanbul rows being newer cars.

The city is a field of the listing and does not come from your IP address. At country level, however, location matters. Some sites show a different version, currency or set of listings depending on the visitor's country. If you are reading another country's market, you need to look from that country. Here a Residential Proxy sends the request out through a home connection in the country you choose. We explained how country and city targeting works in How Does Country and City Targeting Work in a Proxy?.

Troubleshooting

If the result looks odd, the problem is usually in a step before the analysis.

  • A model has fewer listings than expected. Spelling variants stayed in separate groups. Look for similar names in the output of df["model"].value_counts() and add them to the mapping dictionary.
  • The loss per kilometer is very large. The model was fitted on mileage alone, and the effect of age rode on mileage. Add age to the model or look at a single year.
  • The average price is far too low. The unit slipped in a few rows: 1,2 milyon (1.2 million) or 120 bin km turned into the wrong number. Run the range check.
  • A city group is split in two. İstanbul was lowercased and picked up a combining dot mark. Map the city against a fixed list.
  • The count of unique cars drops every day. The key is too coarse: different cars with the same equipment are merging. Add color or a seller ID.

For the general form of the cleaning steps, see How to Clean Scraped Data with Pandas in Python.

How we tested

We ran the code on December 2, 2026, with Python 3.13.17, pandas 3.1.2 and NumPy 2.5.5 in a separate virtual environment. The input was a ten-row sample table written by hand: one model, two cities, years 2017 to 2022. We deliberately put three spelling variants into the table, mileage and price as text, and one duplicate listing under two IDs. Every number above is output from this table. We also tested the behavior of the Turkish İ separately on the same Python version.

The bottom line

Fix the names and numbers first, then remove duplicate listings, and model last. Compare cities and countries not by raw median but after removing the effect of age and mileage. Above all, don't model mileage on its own: it carries the effect of age and overstates depreciation. For teams looking at markets in different countries, our market research page has use cases.

Sources

Frequently asked questions

Which fields do you need in car listing data?

Make, model, trim, year, mileage, fuel, gearbox, city, price and listing date are enough. Keep the listing ID too. It does not go into the analysis, but you need it to track price changes and relisting of the same ad. If color and a seller ID are available, keep them as well; they strengthen the duplicate key.

How do you turn "120.000 km" into a number?

By deleting every character that is not a digit. In pandas, run str.replace(r"\D", "", regex=True) and then cast to Int64. Don't use float(): in Turkish notation the dot is the thousands separator, and float("120.000") returns 120. Check the range after the conversion. Rows like 120 bin km turn into small numbers and should go to the manual review list.

How can you tell if the same car was listed twice?

With a key built from make, model, trim, year, mileage band and city. A relisted car usually gets a new ID, so the listing ID is not enough. Sort by date and keep the latest price with drop_duplicates(keep="last"). Before deleting, write the first listing date to a separate column. Time on market comes from that column.

How do you calculate depreciation per kilometer?

By modeling price against mileage within a single model year. If you mix all years and look at mileage alone, the effect of age rides on mileage and the loss comes out large. The alternative is to put age and mileage in the same model. If the two are very strongly correlated, the model cannot separate their shares; then go back to a single year.

How do you measure price differences between cities?

With the deviation left after removing the effect of age and mileage. The raw median also reflects the mix of age and mileage among the cars in each city. In our sample table the median gap was 122,500 TL, while the adjusted gap came out at about 1,800 TL. Comparing within the same model and trim matters too. If a group has few listings, don't publish the gap.

What does a proxy do in car listing analysis?

It lets you look from the right location at country level. Some sites show a different version, currency or set of listings depending on the visitor's country. When you read another country's market, an IP from that country gives you the result a local buyer sees. You don't need it for city differences, because the city is a field of the listing itself.

Ask ChatGPTAsk Claude