Live data from Hacker News

Python is not a great language for data science

blog.genesmindsmachines.com

241–250 of 339 posts

Re: Python is not a great language for data science

#241
post #146

Earlier quoted context omitted.

R is more of a statistical software than a programming language. So, if you are a so-called "statistician," then R will feel familiar to you

No, R is a serious general purpose programming language that is great for building almost any type of complex scientific software with. Projects like Bioconductor are a good example.

No, it's not. Even established packages have bugs caused by R weirdness. I like it nevertheless.

Re: Python is not a great language for data science

#242
post #136

Earlier quoted context omitted.

I hear this so much from Python people -- almost like they are paid by the word to say it. Is it different from Perl, Ruby, Java, or C# (DotNet)? Not in my experience, except people from those communities don't repeat that phrase so much. The irony here: We are talking about data science. 98% of "data science" Python projects start by creating a virtual env and adding Pandas and NumPy which have numerous (really: squ…

Someone correct me if I'm completely wrong, but by default (i.e. precompiled wheels) numpy has 0 dependencies and pandas has 5, one of which is numpy. So not really "squillions" of dependencies. pandas==2.3.3 ├── numpy [required: >=1.22.4, installed: 2.2.6] ├── python-dateutil [required: >=2.8.2, installed: 2.9.0.post0] │ └── six [required: >=1.5, installed: 1.17.0] ├── pytz [required: >=2020.1, installed: 2025.2] └─…

Read https://numpy.org/devdocs/building/blas_lapack.html.

NumPy will fall back to internal and very slow BLAS and LAPACK implementations if your system does not have a better one, but assuming you're using NumPy for its performance and not just the convenience of adding array programming features to Python, you're really gonna want better ones, and what that is heavily depends on the computer you're using.

This isn't really a Python thing, though. It's a hard problem to solve with any kind of scientific computing. If you insist on using a dynamic interpreted language, which you probably have to do for exploratory interactive analysis, and you still need speed over large datasets, you're gonna need to have a native FFI and link against native libraries. Thanks to standardization, you'll have many choices and which is fastest depends heavily on your hardware setup.

Re: Python is not a great language for data science

#243
post #194

I at the moment try to learn python as a hobby language. I use c c++ and c# to earn my money. MY biggest problem is finding good examples that are up to date. I spent a whole day learning that there a four (I think) ways to do formatting strings. This „bloat“ in syntax makes even a simple print very heavy to digest. I don’t even bother using v2 python only v3. Also using whitespaces to block things together sounds ap…

You seem to be making things more difficult for yourself than they need to be. For the strings, just use f-strings and forget all the others. You can even do things like this for debugging: >>> class User: ... pass ... user = User() ... user.name = "Surac" ... >>> print(f"{user.name=}") user.name='Surac' >>> For the block indenting, what editor are you using? Pretty much every modern editor lets you select a block an…

I think their point is that it's not clear to someone with 0% Python experience which of the /many/ different ways of doing things (like string interpolation) is the "correct" / idiomatic way.

Re: Python is not a great language for data science

#244
post #16

I think a lot of this comes down to the question: Why aren't tables first class citizens in programming languages? If you step back, it's kind of weird that there's no mainstream programming language that has tables as first class citizens. Instead, we're stuck learning multiple APIs (polars, pandas) which are effectively programming languages for tables. R is perhaps the closest, because it has data.frame as a 'firs…

Well you nailed it, the language you're looking for is SQL. There's a reason why duckdb got such traction over the last years. I think data scientists overlook SQL and Excel like tooling.

Out of the current options, I strongly agree - I even wrote a blog post! https://www.robinlinacre.com/recommend_sql/

But on the other hand, that's doesn't mean SQL is ideal - far from it. When using DuckDB with Python, to make things more succinct, reusable and maintainable, I often fall into the pattern of writing Python functions that generate SQL strings.

But that hints at the drawbacks of SQL: it's mostly not composable as a language (compared to general purpose languages with first-class abstractions). DuckDB syntax does improve on this a little, but I think it's mostly fundamental to SQL. All I'm saying is that it feels like something better is possible.

Re: Python is not a great language for data science

#245
post #72

> Examples include converting boxplots into violins or vice versa, turning a line plot into a heatmap, plotting a density estimate instead of a histogram, performing a computation on ranked data values instead of raw data values, and so on. Most of this is not about Python, it’s about matplotlib. If you want the admittedly very thoughtful design of ggplot in Python, use plotnine > I would consider the R code to be sl…

"The reason you can use this simpler syntax in R is because it’s non-standard-evaluation ..." So it actually is about Python vs R. That said, while this kind of non-standard evaluation is nice when working interactively on the command line, I don't think it's that relevant when writing code for more elaborated analyses. In that context, I'd actually see this as a disadvantage of R because you suddenly have to jump th…

The increasing prevalence of non-standard evaluation in R packages was one of the major reasons I switched from R to python for my work. The amount of ceremony and constant API changes just to have something as an argument in a function drove me mad.

Re: Python is not a great language for data science

#246

Article is well written but fails to address its own thesis by postponing it to a sequel article. At its current state only alludes that Python is not great because requires specialized packages. (And counterexample is R for which also used a package.)

The 'sequel' is also online: https://blog.genesmindsmachines.com/p/python-is-not-a-great-...

Re: Python is not a great language for data science

#247
post #145

Doing computational biology for several decades in about a dozen languages, I do think R is a much better language for data science, but in practice I end up using Python almost every time because it has more libraries, and it’s easier to find software engineers and collaborators to work on Python. However, R makes for much simpler cleaner code, less silent errors, and the 1 indexing makes dealing with biological seq…

In my experience R is king of happily chugging along spitting out nonsense results when it should have errored 100 lines ago.

Re: Python is not a great language for data science

#248

Excellent article - except that the author probably should have gated their substantiation of the claim behind a cliffhanger, as other commenters have mentioned. The author's priorities are sensible, and indeed with that set of priorities, it makes sense to end up near R. However, they're not universal among data scientists. I've been a data scientist for eight years, and have found that this kind of plotting and dat…

The second part of the article is right here: https://blog.genesmindsmachines.com/p/python-is-not-a-great-...

Re: Python is not a great language for data science

#249
post #16

I think a lot of this comes down to the question: Why aren't tables first class citizens in programming languages? If you step back, it's kind of weird that there's no mainstream programming language that has tables as first class citizens. Instead, we're stuck learning multiple APIs (polars, pandas) which are effectively programming languages for tables. R is perhaps the closest, because it has data.frame as a 'firs…

There are a number of data-focussed no-code/visual/drag-and-drop tools where data tables/frames are very much a first class citizen (e.g. Easy Data Transform, Alteryx, Knime).

Re: Python is not a great language for data science

#250
In the article

> Contrast this with equivalent code that is full of logistics, where I’m using only basic Python language features and no special data wrangling package:

   n = len(values)
   # Calculate mean
   mean = sum(values) / n
   # Calculate standard deviation
   variance = sum((x - mean) \* 2 for x in values) / (n - 1)
   std_dev = math.sqrt(variance)
He doesn' t know about the statistics package in the standart library of Python (https://docs.python.org/3/library/statistics.html). Of course, if you do not know to use Python, you will have a lot of boilerplate.
Post reply on HN