Skip to main content

A package containing data on Qatari cars for pedagogical purposes

Project description

QatarCars – Modern Passenger Cars Data

QatarCars is a lightweight CSV describing modern passenger cars from around the world. The aim is to give students a small, well‑structured dataset that still covers a range of data‑science tasks (merging, filtering, statistics, machine‑learning). It was originally created in 2025 by Paul Musgrave and his International Politics statistics class at Georgetown University. This package ports the dataset into Python and allows users to decide whether to engage with the data as either a pandas or polars dataframe. QatarCars is available in its original form as a csv, in Stata, and as an R Package.

Installation

From pypi:

pip install qatarcars

From GitHub:

pip install git+https://github.com/prlitics/qatarcars.git

What’s Included?

Column Description
origin A string denoting nation of origin of the car
make A string denoting the manufacturer/brand of the car
model A string denoting the specific type of the car
length A float denoting the car’s length (in meters)
width A float denoting the car’s width (in meters)
height A float denoting the car’s height (in meters)
seating An integer denoting how many seats are within the car
trunk An integer denoting the trunk’s volume (in liters)
economy A float denoting how many liters of fuel is required to travel 100km
performance A float denoting how many seconds it takes to accelerate to 100km/h from a dead stop
mass A float of the car’s mass (in kg)
price An integer of the vehicles’ price (QAR)
horsepower An integer denoting the car’s horsepower
type A string denoting the body-type of the car
enginetype A string denoting the type of fuel/energy used by the engine

Polars or Pandas? You decide!

Pandas is pretty much ubiquitous in Python data analytics, often considered the “default” implementation of a dataframe. However, Polars is gaining in popularity because of its more consistent and (especially comming to Python from R) intuitive syntax. It’s also very fast, which can be great when dealing with large data. However, the syntax of Polars compared to Pandas is often quite different. So, for pedagogical/learning purposes, I’ve made it so that the core function for the package get_qatar_cars can return either a pandas or polars dataframe. It’s up to you!

Examples

Let’s look at the first few observations. We’ll visualize using plotnine which is a great import of the ggplot2 package into Python.

from qatarcars import get_qatar_cars
import plotnine as p9

from qatarcars import get_qatar_cars
df = get_qatar_cars("pandas")   # or "polars"

df.head()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
origin make model length width height seating trunk economy horsepower price mass performance type enginetype
0 Germany BMW 8 Series Gran Coupe 5.082 1.932 1.407 4 440 7.2 340 435000 2090 5.2 Coupe Petrol
1 Italy Bugatti Centodieci 4.544 2.047 1.200 2 0 22.5 1600 33000000 1976 2.4 Coupe Petrol
2 Germany Porsche 991 Carrera S 4.510 1.852 1.300 4 132 11.2 473 530000 1495 3.3 Coupe Petrol
3 Japan Lexus RC F 4.695 2.069 1.395 4 66 11.5 471 320000 1770 4.5 Coupe Petrol
4 Japan Toyota Supra 4.379 1.854 1.292 2 290 7.2 382 220000 1410 4.1 Coupe Petrol

I’m curious how much a vehicle’s weight impacts its ability to get to 100 km/hr from a dead stop?

(p9.ggplot(df) +
p9.aes(x = 'mass', y = 'performance') +
p9.geom_point() +
p9.geom_smooth() +
p9.labs(x = 'Mass (kg)', y = 'Time to 100km/h \n(seconds)'))

Does this change based on what kind of drivetrain it has?

(p9.ggplot(df) +
p9.aes(x = 'mass', y = 'performance', group = 'enginetype', color = 'enginetype') +
p9.geom_point() +
p9.geom_smooth() +
p9.labs(x = 'Mass (kg)', y = 'Time to 100km/h \n(seconds)'))

Interesting! Electric cars take more of a performance hit the heavier they get whereas hybrids and petrol-based vehicles tend to flatten out in their performance.

Let’s check out the distribution of cars by body type in the dataset.

(p9.ggplot(df) +
p9.aes(x = 'type') +
p9.geom_bar())

A lot of SUVs!

Have fun! 🚗

License

The qatarcars python package is licsensed with a CC0 1.0 Universal (Creative Commons) license. Have fun with it!

Bibliography

See also:

  • {qatarcars} R package version from Andrew Heiss and Paul Musgrave

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qatarcars-0.2.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qatarcars-0.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file qatarcars-0.2.0.tar.gz.

File metadata

  • Download URL: qatarcars-0.2.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.11 Windows/11

File hashes

Hashes for qatarcars-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8ec4b7573bb81cb10d3cb03134d1aebb5d9ea868cd0f4090571ed52bf5b0c397
MD5 2f158ec0d2ff0d1314caba4d403daafe
BLAKE2b-256 a90b5db30241f2f8b368766cd4cbaa9a4a37157cfcfcda0426a057230a1b57e0

See more details on using hashes here.

File details

Details for the file qatarcars-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: qatarcars-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.11 Windows/11

File hashes

Hashes for qatarcars-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d70863c19e0866eb63f76cbf88216799b21e66380e1631e83605f55b4c0cca3c
MD5 01bedb672e9d306a18866479b1e75c93
BLAKE2b-256 72259bb156b274f5186be0c9069bc863e9cf10cb0b4b1b9a6b8e244c875f5262

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page