SQL is dead! No it's not. Neither is Pandas. Wouldn't it be nice if you could use SQL over Pandas syntax when dealing with a Pandas DataFrame? Fortunately, you can using DuckDB! 🦆 DuckDB is an open source in-process database management system. Do you prefer SQL over Pandas? Let me know in the comments. If you would like to see more Python tips, along with operations research and career content, then please feel free to follow me on LinkedIn. #python #sql #data #ai
I found myself switching back & forth. Certain operations easier in sql and others easier in python. Most common reason I'd switch to duckdb in a python process like above is if I wanna join two tables with a ≥ or ≤ match e.g. SELECT * FROM accounts as a LEFT JOIN orders AS o ON a.account_id = o.account_id AND o.order_created_date ≥ a.account_created_date The pandas/python equivalents are just too fiddly for my taste and harder to read
I need to give duckdb a chance already. I love both pandas and SQL. Really depends on the situation. Pandas/Spark are great for cleaning and things like pivoting/melt, while I prefer SQL for aggregations and filtering (although loc function is pretty handy). With pandas you can read multiple files in pretty easily (especially with AWS Wrangler library) without having to worry about all the schema details. It is a great way to preview a parquet file or Jason file without having to create a whole table in your Warehouse.
They both have a lot of use cases, when im doing a lot of machine learning I use more python and Pandas, but when it comes to integrating into dashboards and quick data access I find myself using SQL more.
Pandas might almost be dead. Polars is quite a bit better. Still won't quite be dead because nothing ever dies completely in software even when it should.
I would rather use sql for everything.
I use both for my work. It's not even a matter of preference for me more-so as this would help me avoid silly formatting mistakes that I occasionally make when I am switching between the two coding languages in the same day!
For me if anything gets mildly complicated in SQL (or excel) I switch to Python. The world is my oyster using pandas to clean and transform data.
Recently used it in my R work and it was cool.
don’t do that. (Senior level folks know what I mean)