Italian Real Estate Prices with Streamlit
Playing with public data, Streamlit, and a pile of new tools to answer the age-old question: what’s a fair price for a home in Italy?
I found out that the Italian Revenue Office (Agenzia delle Entrate) has some data, that can be requested by citizens, about real estate prices. You can ask for a csv of a specific semester in any year since they started collecting it.
Since I moved back I started being interested in the Italian real estate market because I might want to buy soonish. However here the market is very different from what I’ve been used in Ireland.
In Ireland when you want to sell your house you set a price, usually pretty low, to get people in the door and then there will be an auction with all interested parties bidding against each other until a set time.
In Italy, usually, they set a higher price, higher than what they’d settle for and then you negotiate down to meet in the middle.
So the question I want an answer for is: what is a reasonable price for the kind of apartment I might be looking for?
If I just look at the ads on the usual websites I only get one side of the medal. Unfortunately there’s no open property price registry in Italy where you can just browse how much a property was sold at. There are ways, using SPID (a form of ID you can use in Italy to access a bunch of governmental websites) to know sale prices up until the building, but you have to know exactly what you’re looking for and there is no way to scrape it or get an overview.
From Excel to Streamlit (with several detours)
Once I requested the CSV dataset from the Italian Revenue Office, I was this close to opening it in Excel. But then I thought… nah. That’s not the vibe.
I wanted to explore new tools. I wanted a better way to slice and understand the data. So I built this little web app using Streamlit. It’s simple, but it works. And apart from a touch of Python, I used a whole stack I’d never touched before:
uv
(instead of pip)DuckDB
(lightly)Streamlit
for the UIGithub Actions
for automationCloudflare Tunnels
for easy deploymentAnd a healthy dose of curiosity
Source code’s here, by the way: GitHub repo
Building it, breaking it, fixing it
The codebase is admittedly a bit messy. I even tried building an interactive map of Italy, clickable down to the municipality level, but that rabbit hole got deep fast. Priorities, right?
Here are a few small things that worked:
To avoid re-creating tables on every reload, I used a quick DuckDB check:
try: conn.execute("SELECT 1 FROM _initialized LIMIT 1")
Plus a simple table init block:
conn.execute("CREATE TABLE _initialized (initialized_at TIMESTAMP);")
conn.execute("INSERT INTO _initialized VALUES (CURRENT_TIMESTAMP);")
I cached dropdown options like this:
@st.cache_data(hash_funcs={duckdb.DuckDBPyConnection: id})
def get_regions(conn):
return conn.execute("SELECT DISTINCT Regione FROM luoghi ORDER BY Regione").df()
And I used some very naïve
if
logic to keep state across Streamlit reloads. It works… mostly.
As for uv
, I have to say: it’s smooth. Definitely faster than pip, with solid docs and zero headaches. I might keep using it.
And then there’s GitHub Actions. Somehow, after over a decade in tech, I’d never used it. I’ve worked with GitLab CI, Jenkins, Azure Pipelines…you name it. But GitHub Actions felt refreshingly powerful. You could run entire data pipelines there for free. Should you? Probably not. Could you? Definitely.
Last shoutout: Cursor. That thing is an absolute productivity cheat code. Way beyond Copilot. I still need to try Windsurf, but wow!
Here’s a bonus pic of me, deep in Cursor mode:
What’s next?
The data is useful, but not perfect. It doesn’t factor in property conditions or energy ratings, so there’s still a gap.
Next step? I’d love to compare this dataset with listings from popular real estate websites to see how asking prices stack up against actual transaction averages. That’ll also give me a better excuse to explore DuckDB more seriously.
Another idea: loading all the historical files to build a time series of prices across regions and municipalities. Because nothing says “fun” like a good old price trend analysis.
Want more nerdy real estate experiments and data deep-dives like this? Hit subscribe and stick around.
Intersting and useful! Not familiar with webapps here, where do you host the app?