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)
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 3 Series Convertible 4.713 1.827 1.440 5 480 11.8 184 190300 1777 5.8 Coupe Petrol
1 Germany BMW 3 Series Sedan 4.713 1.827 1.440 5 59 7.6 386 164257 1653 4.3 Sedan Petrol
2 Germany BMW X1 4.505 1.845 1.642 5 505 6.6 313 264000 1701 5.4 SUV Petrol
3 Germany Audi RS Q8 5.012 1.694 1.998 5 605 12.1 600 630000 2490 3.6 SUV Petrol
4 Germany Audi RS3 4.542 1.851 1.412 5 321 8.7 400 310000 1565 3.8 Sedan 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.1.0.tar.gz (11.1 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.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qatarcars-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 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.1.0.tar.gz
Algorithm Hash digest
SHA256 53cf37a2185241e5b48b77e7d886eecc8f80d2fa661635df423f17bc57776ae6
MD5 4aba40f0023ee9702f55c2e08a99a451
BLAKE2b-256 f9179f8422838fd80516c2fcf97e599cdb03e92a9ac0bcbe3c18d0d6393b6aab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qatarcars-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c78511199132c78919b870e66b296adec65a23ba104d48cce1a28ced495fba2
MD5 9cdb8ebabadbef11f01339b6694a0307
BLAKE2b-256 71e89992addfec6277515b4acc0e924c377e5d784b4719dd7f51a0f510d8e457

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