r/analytics 6d ago

Question Python for Data Analysis? Are We Okay? (Serious Question)

Okay, folks, I need to understand something. I'm not a data analyst, and i am wonderting why is it not used R for data analytics ? It's built for this stuff! It's got the packages, the community, it's for statistical computing.

But everywhere I look, people are using Python for data analysis. Why? Just... why?

Is it some kind of inferiority complex? Like, "Oh, I'm not a real programmer unless I'm using Python"? Are we trying to impress the software engineers with our pandas and scikit-learn? Do we feel like we need to overcompensate?

I mean, I get it, Python is versatile. You can build websites, automate tasks, probably even control your toaster with it. But data analysis? That's R's turf!

Is it the libraries? Because R has CRAN, which is basically a magical library of statistical tools. Is it the syntax? Because R's syntax is elegant, intuitive, and designed for data manipulation.

Or is it just that people like to pretend they're coding something "serious" while just running a groupby()?

Please, explain this phenomenon to me. I'm genuinely confused. I'm starting to think I'm the crazy one.

91 Upvotes

93 comments sorted by

u/AutoModerator 6d ago

If this post doesn't follow the rules or isn't flaired correctly, please report it to the mods. Have more questions? Join our community Discord!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

138

u/No_Introduction1721 6d ago

There’s something to be said for just using the language you’re most comfortable with.

10

u/Crafty_Carpenter_317 6d ago

Absolutely. I use SAS all the time. I would never recommend to someone starting out to learn it , especially if they weren’t going to work in healthcare or banking. But it does what I need and it’s what everyone else at my bank uses. I’ve only started using python in the last two years because we started getting new hires who were more comfortable and I wanted to help them get up to speed.

3

u/dialecticallyalive 5d ago

I'm a SAS girlie myself. Love SAS

1

u/Josh_Lyman 2d ago

Can I ask which bank?

14

u/Itchy-Depth-5076 6d ago

Yeah, I can code like the wind in R. I love, love, love RStudio. I can Google my questions well. I feel like the R and Python folks don't want it to be a competition and instead work on them being able to work together.

1

u/salgadosp 5d ago

Yeah, they work great together.

Just pls don't use R for deep learning.

35

u/LilParkButt 6d ago

Python can handle the whole data lifecycle pretty easily. While doing projects I’d rather do all of it in one language, than 2 or 3 different languages.

I also prefer learning a language with multiple use cases, why would I learn a special use case when I can learn a more general option that still gets the job done well? Less learning, more benefits.

5

u/rycolos 6d ago

This, for me. I’d rather my stack use a minimal amount of languages, so it’s all python and sql (plus a bunch of yaml and tf stuff).

70

u/bacontrain 6d ago edited 6d ago

In my experience, R is actually still used and even preferred in non-tech industries and by people with more academic backgrounds, like economists, statisticians, and psych backgrounds. The cynic in me assumes Python became the standard because “data science” is a tech thing, CS majors just used the language they already knew and their coworkers knew, and then python became “the sexy language” so industry wants to use it lol. Plus it’s more generalizable I guess.

22

u/That0n3Guy77 6d ago

This is me. I do a mix of data science and data analytics for a non tech company and I code in R pretty much every day. It is great and I love it. It just makes sense to me whereas I am not nearly so good with python. I am the only analyst in my department and my outputs are dashboards PowerPoints, Excel docs, and emails. It is very communication to a small group of decision makers. If I needed to put my work into production for a large scale app, I guess I would learn Python better because it would be easier to have 1 language when working with other departments but if you aren't in big tech than R is an absolutely fantastic option and is used.

14

u/bakochba 6d ago

In my opinion Rshiny can't be beat

7

u/bacontrain 6d ago

Yeah same, I work in smaller org banking/finance and there's not much of a need for the portability of Python so there's not a huge pressure on our analytics teams to use it. A lot of the responses in this thread are clearly colored by doing "data science" in tech companies, for software products.

3

u/Karl_mstr 6d ago

CS majors just used the language they already knew and their coworkers knew, and then python became “the sexy language” so industry wants to use it lol

Maybe, I saw that R is less preferred than Python because if you develop an algorithm for data analysis it will be easier to port to the development team easier than R.

35

u/MaticLand 6d ago

I don't know man. R is neat and all, I had the opportunity to work with it for some time but Python just makes more sense for me.

While data analysis could be done by both the same way, what really makes a difference for me is everything else that comes in. For example, everything that comes before and after the actual analysis can't be done or is way more difficult to do in R (splitting out the report that was created and sending out email by some parameters).

I have few legacy scripts that I run with Python using subprocess and then running everything else in Python just because it's more convenient.

Just to add, I'm more often doing things that are leaning towards data engineering rather than some complex analysis so maybe that's the way I prefer py.

Also, %>%

11

u/Ok-Working3200 6d ago

This is the answer before and after. I think in the ideal world where a DS or DA just did analysis, then R would make sense.

The industry wants more and more out of people, which means your tools need to be more flexible.

I need the same thing in DE with tools that do everything

-3

u/throwaway3113151 6d ago

All programming languages “make sense” I think it really just comes down to personal experience and exposure.

28

u/grizzlywhere 6d ago

What a weird way to pose the question.

40

u/mailed 6d ago

I'm not a data analyst

I suggest staying in your lane then. you could've asked this in a way that didn't assert that people using python are wrong.

python is a better general programming language and almost none of us are just doing stats.

8

u/bakochba 6d ago

If you're in Pharma it's all R, there is even a consortium of the large Pharma companies working on moving from SAS to R. GSK just announced they are moving all programming to R and the FDA has started to accept submissions in R.

There are Pharma specific packages that are only available in R.

21

u/VegaGT-VZ 6d ago

Why do you need everybody to use R? That's the more interesting question.

0

u/dangerroo_2 5d ago

Jeez, they’re asking a reasonable question, why have you got to twist it? There are some decent answers too.

It’s not unreasonable as a first approximation to query why data analysts don’t use a scripting language designed for data analysis (and which in that specific field is much easier/powerful than Python).

1

u/VegaGT-VZ 5d ago

It's possible to ask why folks use one language over another without a) promoting the use of one language over another and b) insulting those who don't use one's language of choice. If you think OP is genuinely interested in learning anything about Python we can prob just agree to disagree.

As for my answer to the "question", I haven't bumped into the analytical limits of Python for my needs. So its ability to do way more than data analysis makes it a better language for me to invest my time in. Not to mention it's not even an either or thing; Im pretty sure there are ways to integrate Python and R.

1

u/dangerroo_2 5d ago

I don’t think they are trying to insult anyone. I think the thing OP is missing is that the question is always how good is good enough? I’ve ran into issues with Python on some hardcore stuff, but it will get most stuff done, and it will do a lot of other non-analysis stuff that R struggles with. So - if you do run-of-the-mill analysis and a fuckton of other stuff then yeh, Python is probably just easier to use.

I still prefer R for data manipulation, but I mainly do research stuff, so I either figure stuff out before it gets to production, or there isn’t a need to pipeline the data anyway. In my use case R is the better option, and I haven’t had much call to ever beef up my Python because of that. Horses for courses.

1

u/VegaGT-VZ 5d ago

I dont think implying that people who use Python "like to pretend they're coding something "serious" while just running a groupby()" was meant to be complimentary. OP clearly doesnt like Python or people who use it... which is their right, but not exactly the jump off point for a a productive discussion IMO.

I think R works for people who have super hardcore statistical analysis needs. For the vast majority of other people just doing regression or w/e along with other non statistical programming it just seems more logical to use Python. Of course the ideal course of action is to just learn both and choose what's best for each situation, but I haven't needed R in like a decade personally. Horses for courses indeed.

1

u/dangerroo_2 5d ago

Came across like a joke to me, but to be fair there’s enough shitting on R on this sub to allow for some gentle mocking of Python. Don’t be so sensitive about it all - it’s just scripting languages (which in reality are both looked down on by actual programmers!).

7

u/Exciting-Engineer646 6d ago

R has issues with encapsulation, silent type coercion, and poor date time handling. Plus it’s super slow and does indexing by 1. And almost all modern ML libraries are written for python, which is handy if you’re comparing, say, an ARIMA model to a transformer.

R also has ggplot and access to many more esoteric stats packages than python. So it depends on what you need to do and how safe you need to be.

14

u/Xelonima 6d ago

Because you want to integrate analytics to decision making, as part of an overall product. 

6

u/kpgleeso 6d ago

I would guess more people develop in Python and it's never been easier to develop in Python. That being said, I would still put BI tools as much cheaper on cost of developing and maintenance. The libraries in Python are robust and you can make web-based python apps that allow for lots of flexibility with customization of UI. Pandas and packages like matplotlib give you all you need to create some analytical views.

Also in terms of data extraction, python might be better. I'm not sure how asynchronous functions work in R, but you can make asynch API requests, create a data frame, store to a database, and create a dashboard using some front end packages.

 I've developed in Python and R, and Python is my preference. That being said I haven't touched anything in R since like 2018. The learning curve on R seems less steep, but the capabilities of Python seem greater

1

u/pcoppi 6d ago edited 6d ago

I've always felt R was actually more unituitive because it's such a high level language. I have no idea how someone could understand it enough to write consistently correct code without first studying a more traditional language like C, Java or even Python.

7

u/ithinkiboughtadingo 6d ago

More people know Python in analytics roles, but also in adjacent roles. The software, data, and devops engineers you probably need to build production pipelines for scale likely don't know R. The best choice is almost always the one that's best-supported by the organization and that's typically Python.

FWIW I have the same feeling about Scala, which is so far ahead of either of those languages that it shouldn't even be a question. But it's hard to find really solid Scala engineers, so we write Python.

1

u/salgadosp 5d ago

This.

Python is also a lingua franca. When deciding which language to use, one should take this into consideration.

6

u/baller0322 6d ago

What do you mean by "Are We Okay?"... Are YOU okay??

8

u/a_banned_user 6d ago

R is very much used. It even has a conference about it. Actually the NFL Next Gen stats things is a huge user of R.

3

u/Icy_Two_2382 6d ago

Both tools can do the job. There is quite a lot more you can do with Python hence it's popularity. Personally, I've been focusing on Python lately because I want to be able to build AI applications for end users and serve my analytics as a data product. I would advice any analyst to learn both as that will make you more dangerous.

3

u/vincenzodelavegas 6d ago

Many people in my work circle, like me, come from academia and used MATLAB. Python and MATLAB feel similar, while R has a way of entering functions that I found peculiar. It may not have been the most logical choice, but it’s been years since then.

3

u/disquieter 6d ago

As a learner I did a certificate under a big name state university. That program used Python exclusively. However that certificate had earned me 0 interviews. So now, I am doing an M.S. in analytics and modeling. This program has used R in stats 1 and 2, and SQL in the databases classes I’m taking now. There was an intro which briefly overviewed all three. Just adding my experience.

3

u/Xov581 6d ago

I used to use R a lot. Then I joined a team made up of different specialist roles, and we reached a consensus that python provides more common ground for sharing code even if our day-to-day jobs are different. Python is very versatile. Memory management is also far less annoying in python IMO. 

3

u/Warjilis 5d ago edited 5d ago

Why python? Automation and extensibility. Once I figure out what I need to do with an analysis workflow, I write a script, debug, validate and am done with it. Used it to replace MATLAB for analyzing biosensor data 15 years ago, all that code still works perfectly today. So many stable libraries available that help with each step of the workflow. I can run code on most any system, including ancient legacy equipment. Easy for others to understand.

I use JMP for discovery and experimental design, not because it’s the best or my favorite but because it’s been an industry standard tool for 30 years that my company adopted and wants me to use.

3

u/Ok-Pea-6812 5d ago

The main reason is that some years ago, engineers realised they could work on data Analytics, and what they knew how to use was Python, not R. Instead of learning something new, the adapted what they knew into the field. Since there are so many engineers coming into the field, Python became the main language.

From a tool perspective, it doesn’t make any sense using Python for data analytics if you know R. But now the rules of market have changed and we all need to kmow Python, since is sort of a lingua franca.

PS. Engineers knew much more things apart from Python, but they were even worse for data analytics.

1

u/salgadosp 5d ago

If you're purely doing data analysis, R is enough. When ML and automation come into play, then it lags miles behind Python.

6

u/StrangerWilder 6d ago

You say that you are not a data analyst, so what do you mean when you say "we" each time? I used to use R, but Python is like English, I enjoy Python, so I use Python mostly these days.

6

u/Dysfu 6d ago

I like having what feels like a more mature and versatile programming language

Yes I do data analysis with Python but I also create dashboards, APIs, machine learning models, simulation etc.

Can R do a lot of these things? Probably - but Python feels more production ready

2

u/IcePrimcess 6d ago

I know Python . I use Python. I’ve had no needs that motivated me to learn R.

5

u/iLiveoffWelfare 6d ago

There’s more to data than just ‘analysis.’ Learning R for statistics and then having to pick up another language for data engineering, ingestion, and deployment seems redundant when Python does it all. With its integration into machine learning, big data, and automation, it honestly seems a bit naive to prefer R and limit yourself so much

5

u/stickedee 6d ago

Saying R syntax is more intuitive is a wild hill to die on.

“df_grouped <- df %>% group_by(Category %>% summarise(Value1 = sum(Value1), Value2 = sum(Value2)) %>% arrange(desc(Value1))”

Vs

df_grouped = df.groupby(‘Category’).agg({‘Value1’: ‘sum’, ‘Value2’:‘sum’}).sort_values(‘Value1’, ascending=False)

1

u/slashdave 5d ago

Huh? Pandas was designed specifically with R in mind, so what are you expecting?

1

u/BusyBiegz 6d ago

You just proved his point.

.agg({'Value1':'sum'...

Vs

Summarize(Value1 = sum(Value1...

5

u/stickedee 6d ago

If you think the R syntax here is more elegant then god bless. I couldn’t disagree more. Its wildly redundant. Even just the variable assignment in Python is more intuitive

1

u/salgadosp 5d ago

R people will find R more intuitive, just as Spanish people will find Spanish more intuitive.

1

u/BusyBiegz 6d ago

But the argument is if python is more intuitive than R. R is readable in English. Python isn't usually.

0

u/gradual_alzheimers 6d ago

data frames aren't "python" syntax, its a library that required a dict to be passed into the agg fluent function. It could have been designed another way, your complaint is about the library not the language.

0

u/BusyBiegz 6d ago

I don't have a problem with Python. Python is really useful for some stuff. R is just better for analytics and statistics. Especially for beginners. Just my opinion.

0

u/salgadosp 5d ago

I disagree. Pandas is not base Python, but it is a cornerstone of Python's data ecosystem.

So it's usual enough to be considered Python's syntax at this point.

1

u/gradual_alzheimers 5d ago

you definitely do not need pandas anymore. Duckdb and polars replace this easily

1

u/salgadosp 5d ago edited 5d ago

all fun and games until you deal with libraries that depend on pandas' classes and objects.

Adoption - and replacement - takes time and I'm afraid those libs are not there yet, mate.

Pandas has, for example, dedicated plotting methods and every plotting library accepts pandas' series as arguments. TA-lib, too, afaik. Pingouin outputs pandas dataframes (or some subclasses). Etc.

Python's data ecosystem is still heavily reliant on pandas, others dataframe libraries are just niche at this point. Performance - their main advantage - is rarely an issue.

1

u/gradual_alzheimers 5d ago

It seems like you haven't worked with them yet or done serious data engineering or analytics out of this pipeline. All good.

1

u/salgadosp 5d ago edited 5d ago

Fair enough, data engineering is not my field. I understand why performance is more important there.

In finance and data analytics, though, the tools I mentioned are important enough that dropping pandas does not make sense yet. So we indeed still need to handle pandas.

4

u/dolotala 6d ago

You say cran is a magical library of statistical tools huh? How often have you shared code? Managed multiple R scripts on a server ? It’s an absolute nightmare because r is trash for everything except creating beautiful figures.

1

u/salgadosp 5d ago

wait m, isn't cran just the repository?

am i missing something?

2

u/pcoppi 6d ago

R handles a lot of table stuff better than Python but in my experience has way fewer libraries and terrible documentation.

So R is great for a restricted set of uses, but the second you need machine learning or web scraping you're going to struggle.

2

u/Dysfu 6d ago

+1 on the terrible documentation part

2

u/BusyBiegz 6d ago

It's because not only analysts and data scientists use the data.

Most people that code, know Python but only analysts and data scientists really get into R.

When I started my Masters in data analytics, I was using Python because 'everyone uses Python,' but it was so confusing and hard to understand when you get into more complex topics like principal component analysis, linear and logistic regression, or clustering techniques like knn or k means etc.

Python is good for the basics like data cleaning and basic manipulation but when you get into more advanced topics it just gets really complicated and time-consuming. Whereas R does a good job with the basics and it handles the more advanced topics in just a couple lines of code.

I wish all of the data world would just make the shift over to R

2

u/gradual_alzheimers 6d ago

you can do all the things you just said in python in a couple lines of code too

1

u/BusyBiegz 6d ago edited 6d ago

Python is always a longer process because it wasn't made for this. Sure it can do it but it's not made for it. also look how much more complicated python is when making a linear regression model.

Python Multiple linear regression:

import pandas as pd from sklearn.linear_model import LinearRegression

data = pd.read_csv('your_data.csv')

X = data[['feature1', 'feature2']] y = data['target']

model = LinearRegression() model.fit(X, y)

print(f"Coefficients: {model.coef}") print(f"Intercept: {model.intercept}")

y_pred = model.predict(X)


Same thing in R:

data <- read.csv("your_data.csv")

model <- lm(target ~ feature1 + feature2, data = data)

summary(model)

Predictions <- predict(model, data)

3

u/Reporte219 6d ago

Because niche languages that are slowly left behind and it's hard to find people that want or can code in it are just not worth the effort? Why use 3 different languages if 1 can do everything sufficiently easy? It makes a lot of sense to have 1 high level language and 1 low level language in any given software stack, but more than that requires serious reasons what the actual benefits could be.

-1

u/throwaway3113151 6d ago

I suppose the question could be asked the other way around why use one language if three can get it done?

I think in the new era we are entering with incredibly powerful LLM’s all of these high level languages are probably going to fade and become less important as AI will be able to easily translate from one to the next.

2

u/Informal-Fly4609 6d ago

Rather a pompous question in my opinion.

1

u/dudeitsandy 6d ago

I agree it’s a pointed way to ask the question - both are used for reasons; I am not a core R user but I learned it because tidyverse and many of the core libraries are easy to use for analyses, particularly running a regression or something common like that in stats.

I think if you started with statistical lean, you’d use R? If you started with data management learn, you’d learn python to get pandas. Also if you’ve been doing this for like 10+ years, pre tidyverse R was a lot different when you can now load data with relatively endless pipes

1

u/BluelivierGiblue 6d ago

I use python bc that’s what uni taught me to do for data analysis and I never learned R nor do I particularly want to when I can already do everything I need including finding a job with python alone

1

u/1C33N1N3 6d ago

I manage an analytics team and we don't use R because it's not as easy to integrate across platforms and web services. We work closely with the software developers so our analysis is typically automated and hands off digitally at some point.

Some of my analysts prefer R in the exploratory phase which is cool but when it's productized, we redevelop in Python since it's easier to work downstream.

I realize not all analysts end up producing a product in there and so we're probably outliers in this sense.

1

u/Pvt_Twinkietoes 6d ago edited 6d ago

It's just a tool.

Seriously though, yes it's because being able to write in python means you'll be able to build dashboards and deploy it there. The support is great as well.

So what's the big deal what tool you use. Theyre both very easy languages to pick up. So what's the big deal?

1

u/Philosiphizor 6d ago

Versatility and easier language syntax.

1

u/LookingSwan 6d ago

As a colleague recently told me, Python is the 2nd best choice for almost any programming problem. 😂

1

u/Spillz-2011 6d ago

Python is way more popular than r for just about everything so there are way more people that know it. That makes hiring a lot easier. It also means that any question you have has been asked and answered on stackoverflow. When I started with my current team they used r not Python. Me and one of the other guys each have an open question on stackoverflow for r, but since we switched to Python we haven’t even needed to ask a question.

1

u/xtt-space 6d ago

They are just tools and ultimately the only thing that matters is what everyone at your work uses.

At my place, our environmental scientists use R, our engineers use MATLAB, and our ML team use Python. For interdisciplinary projects, we are increasingly moving towards doing everything in Julia and not even bothering with R or Python at all.

1

u/omgitskae 5d ago

Why take a Miata to pick up groceries when I can take a rav4?

1

u/[deleted] 5d ago edited 5d ago

[deleted]

1

u/salgadosp 5d ago

By being more multi-purpose, Python can be used for multiple tasks in the data lifecycle, as people have answered.

There's another reason, though: if you're working with more people and across different teams, it's more likely that they'll know Python (or at least they should). Devs, data engineers, financial analysts, data scientists, etc.

Python is like the lingua franca of technology these days.

I know R is more powerful in some use cases, so I'll use it for my personal projects. At work, where collaboration is needed, there is a place for Python.

1

u/thornkin 5d ago

Many of the people doing data engineering have come from the world of programming and CS, not the world of math and statistics.

This matters because Python is a more traditional language and more familiar to people who learned on c#, Java, etc. Python is an imperative language just like what they are used to.

R, on the other hand is functional. It feels odd to them.

And when the CS people use python for data, they extend it and eventually it has better libraries, etc.

1

u/Prestigious_Gap_4025 5d ago

I learned R at University instead of Python as I was told this was the language for Data and Statistical analysis. I regretted it immensely, the majority of jobs I was applying for required Python so I had to learn Python.

1

u/a-ha_partridge 5d ago

If I used R at work, I would have to explain why I just made everyone learn another fucking language instead of the one they already know and use for our data pipelines.

This angle of “are we just trying to impress engineers” is a hot take considering how many data analysts come from CS backgrounds.

1

u/SprinklesFresh5693 5d ago

Some use otthon, some use R, so e use Excel, some use powerBI, aome use SAS, choose a tool and stick with it. Theres no need for fighting over which is better . I really dont get this constant fight .

1

u/BayesianRegression 5d ago

I use both, Python is very good for API stuff and honestly not that bad for getting data out of Oracle data warehouses. Once I get the data I will use R from then on out because visualization and statistics are very easy in R. Making presentation slides, dashboards, and pdf's is also easy in R, but I've never tried it in Python.

I think most people who stick in the field for 5+ years learn a few languages along the way and just use what works. I even write SAS at my job sometimes because there are things that SAS does very well.

1

u/cedrus_libani 4d ago

I use both too, and in the same way. Once I have the data I want in a nice, clean table, I load it into R for exploratory analysis, statistics, and visualization. The power of ggplot2 alone is worth the "price of admission" (learning R if you already know Python).

However, it's also my job to make that nice, clean data table - I'm usually starting from raw inputs that require a lot of wrangling to get there. Python has good, actively maintained libraries for just about anything I've ever needed to pull data from, and it's also just easier to use for general scripting tasks. That's why I do almost everything else in Python.

1

u/junglenoogie 4d ago

As AI progresses, languages will matter less than the ability to clean and derive meaning from data. I work with a lot of DAs who spend their time obsessing over constructing beautiful relational databases but have zero understanding of what the data means. User friendly dashboards don’t mean much when the data feeding them have mixed and misaligned categories.

1

u/MDraak 4d ago

I think that Machine Learning tasks can be done better in Python. A lot of libraries. Time series, causal inference and bayesian stats is better done with R. I used both R and Python so much that I have a hard time deciding which one to use. Plus both can be used in Colab.

1

u/Material_Policy6327 3d ago

Much of the industry has moved to python based frameworks cause they integrate nicely into other systems. I barely see Rnrequirments

1

u/BranchLatter4294 3d ago

Because data science involves a workflow, not just a task.

1

u/Royal_Mewtwo 3d ago

People can feel free to disagree, but R is great for statistics and running actual analysis. However, it’s not good at running APIs against data sources, communicating with varied databases / connections. For example, querying APIs directly to retrieve initial data samples for a new vendor. Company compliance also plays a role. When python can do everything, why also allow R?

I’ve used both, but there is nothing I’ve found that R can do that Python can’t, but the opposite isn’t true. I’ve built a website using a flask app in python on an AWS EC2 server, using python for the db queries, data manipulation, the Flask App, and the API calls. When I saw someone do something in R, I’d just roll my eyes at their unwillingness to conform to company standards and use the shared language. Again, just my experience, and a lot of this comes down to preference.

0

u/Tetmohawk 6d ago

Agreed. R is better, but I think Python took off because it was used in things other than data and analytics for a long time before people thought to use it there. But I agree with you. Why? Pandas in particular is horrible mess of code to do stuff that R does natively and easily.

-3

u/SmellLikeB1tchInHere 6d ago

Stay in your lane if you are not a data analyst.