[Administrative note: Pandas office hours will take place at 17:00 tomorrow, Israel time, aka 10 a.m. Eastern. It's open to all paid subscribers, including members of my LernerPython+data membership program. Come and ask any Pandas questions you have! Full Zoom info is at the bottom of this message.]
Is the US going to abolish the penny? People have been asking that question as long as I can remember; even when I was growing up in the US, we wondered why the 1-cent coin was still around, other than nostalgia. After all, you couldn't buy anything with a penny, so it seemed rather unnecessary. A number of other countries have done away with their equivalent of the penny, including Canada, as of 2012 (https://en.wikipedia.org/wiki/Penny_(Canadian_coin)).
Of course, doing away with the coin doesn't mean that prices will have to change. When Israel removed the similar 1-agora coin from circulation, it meant that cash purchases were rounded to the nearest 5 agora mark. Electronic purchases and bank transfers remained unchanged, however.
The most recent annual report from the US Mint (https://www.usmint.gov/content/dam/usmint/reports/2024-annual-report.pdf) indicated that 80 percent of purchases are currently digital, meaning that even in the worst-case scenario, 20 percent of transactions might have to worry about pennies. That same report indicated that as of last year, each penny cost 3.69 cents to create, meaning that its face value was less than one third a penny's raw cost. Plus, they found that cash was only used in 20 percent of purchases, making it even less important to have physical pennies.
It's thus not surprising that US Treasury announced earlier this year that it will soon stop minting pennies (https://www.nytimes.com/2025/05/22/us/politics/penny-manufacturing.html?unlocked_article_code=1.Kk8.pHPc.l144zQJcZEc_&smid=url-share). You'll still be able to use them to pay for things -- presumably only at stores that have annoyed you, and against whom you want to take revenge -- but no new ones will be created. And both the UK and the Euro zone still have the equivalent of 1-cent coins, so not everyone is moving in this direction.
Based on this penny news, I decided that it would be fun and interesting to look at coins around the world.
Data and seven questions
This week, our data will come from Numista (https://en.numista.com/), a site with numismatic (i.e., coin-related) information. The site is mainly aimed at coin collectors, including buyers and sellers. But it includes information about enough coins currently in use for our purposes.
In theory, we could query the Numista database enough to find the current value of various coins – but the API only allows for up to 2,000 free queries each month, and I didn't want to use up those queries, when you'll likely make some mistakes along the way, using up your API query count.
Learning goals for this week include working with APIs, JSON files, string processing, regular expressions, and grouping.
Paid subscribers can download the program I used to retrieve from the API at the end of this message. (You'll still need to register for your own API key, though!)
Here are my seven tasks and questions for this week. I'll be back tomorrow with my complete solutions and explanations:
- Assemble a list of dicts about the coins in Numista's database: Using the API, retrieve information about each coin that is in use in 2025. From that data, create a JSON file. The file should be in the form of a list of dicts (or an "array of objects," in JSON parlance). You'll need to sign up for a free Numista account, and then for a free API key at https://en.numista.com/api/api_key.php . You'll then need to use
requests
to ask forhttps://api.numista.com/v3/types
, passing aparams
keyword argument with{'category':'coin', 'q':'circulation', 'count':50, 'year':2025, 'lang':'en'}
as the value, and aheaders
keyword argument with{'Numista-API-Key': api_key}
as the value, whereapi_key
is set to your API key. Iterate, in afor
loop, fromrange(1,10)
, usingrequests.get
to the URL you've constructed, adding the current number (from your iteration) toparams['page']
, so as to request the current page. The response will be in JSON, with the data itself available in the'types'
key, a list of dicts. If the list has length 0, then exit from the loop. Otherwise, add that list of dicts to the list of all coins you've found, and go back for the next page. - Create a JSON file based on the data you've retrieved: Iterate over the list of coin dicts you created. For each one, retrieve from
https://api.numista.com/v3/types/COIN_ID
, whereCOIN_ID
is the'id'
value from the current coin. You'll have to pass the same'Numista-API-Key
' header as before. The only parameter you'll need to send is'lang'
, indicating'en'
for English. Take each returned object, decode it from JSON, and append it to a list of dicts. In the end, usejson.dump
to write that list to a JSON file.