I think this is pretty common in the pandas world right
I think this is pretty common in the pandas world right
The exploratory data analysis part is mostly a product of composability and verbosity. Composability is hard to define succinctly, but an easy example of it would just be the ability to easily define a filter as a variable and then reference that same filter in later code. Python provides a better interface for defining higher-order operations than pgPL/SQL, hands down. As for verbosity, I get data requests at work that require a lot of chained transformations - where I’d have to write 5-10 CTEs and a bunch of GROUP BYs and window functions that would total ~300 lines of SQL. Pandas equivalent would be <50 lines, and also easier to iterate on due to the composability factor. Other “killer-feature” examples of pandas terseness: https://pandas.pydata.org/pandas-docs/stable/reference/api/p..., https://pandas.pydata.org/pandas-docs/stable/reference/api/p....
Feature parity varies by db, but pandas is generally much more expressive and capable than SQL for string munging and time-series stuff.
This is before getting to Jupyter, which blows every SQL interface I’ve ever seen out of the water. One-liner plotting with Pandas is a complete game changer for investigating any unfamiliar dataset; the first class plotting integration is really hard to beat.
All that said, can’t comment on your coworker’s situation without knowing the context. A billion time series datapoints might be fine, but if it’s a wide table using 100s of gigs, probably not smart. I wouldn’t use pandas in a large ETL pipeline without a very good reason, nor would I ever use it for serious joining. If he is just straight up trying trying to functionally replace SQL with pandas code, he’s definitely not doing it right.
(Am data engineer, have been working professionally w/ SQL+Pandas on a near-daily basis for over 3 years.)
Obviously in your case some trivial SQL would have sufficed, which I feel like should have been caught in an interview but could be excused for a junior eng.
Also Pandas is not an amazing choice for data engineering tasks in general IMO, type conversion wonkiness is one reason I have questions about people who decide to use Pandas for legitimate data engineering tasks (as opposed to exploratory work or analysis).
Using pandas but your data doesn’t fit in memory anymore? Here just use this fragile series of packages to distribute it across processors. Don’t reevaluate whether Pandas/Python is still the best choice, just layer more things in.
Run into issues with that approach? Here lift and shift your whole thing into Spark! Don’t ever optimise or actually engineer your process, just layer more things in!!!
Once you have done that, the logic will be easily translatable to SQL, and your brain is prepared for the SQL/relational-algebra way of thinking.
And good luck! You are doing it right!
[0]https://pandas.pydata.org/docs/reference/api/pandas.read_sql...
In general, if you are comparing to an SQL database, the most important is complex anaylsis/manipulation. Of course SQL is great for database level analysis - sorting/filtering/etc. But SQL queries for domain-specific analysis can become very opaque quickly and debugging of complex queries is a mess. Pandas is great for more complex manipulation as it keeps available the wider python ecosystem, allows for simpler debugging of complex processes through a REPL loop, links easily to visualisation, is pretty fast for some things through leveraging things like numpy, in-memory avoids multiple database calls, etc.
Obviously pandas isn't a great choice for persistent large datasets (maybe around the 0.1-1TB mark?) though, simply because it is memory stored.
The use cases definitely overlap significantly, but run into problems (typically ridiculous SQL queries on one side, giant data sets on the other) and you really need to stop and think about the tooling.
SQL is sometimes under appreciated as superior for grouping sorting and filtering... although with Bigquery and KSQL, SQL is definitely finding it's groove again.
You can keep using Panda code for exploratory work, then with a little effort move it to production with Spark runtime.
― Orson Scott Card, Ender's Game
I'm betting you are not an avid Pandas user ;)