Why R Users Find It Difficult to Switch to Python: The Case for Method Chaining

I had started learning python long before I ever used R. Then I started a job where all the legacy codes were in R and I was kind of forced to learn R, albeit reluctantly. But once I get going, I found the language surprisingly good. Before learning python I had mostly used VBA and SAS. The one thing I started liking the most about R was the method chaining in dplyr....

September 2, 2024 · 5 min · 994 words · Maddy

Plotnine compared with Seaborn and its manipulation with matplotlib

We have covered seaborn object interface (https://datavizs.com/posts/python/seaborn_object_interface_24_08_06/) and how we can control properties like color, style, width etc. We also came across a situation where legend was messed up when we came across more complicated situations. We also tried to overcome some of those limitations using matplotlib. It was easy to manipulate seaborn plot with matplotlib because seaborn is built on top of matplotlib and the fig and ax are more natively accessible....

August 14, 2024 · 4 min · 813 words · Maddy

Bridging the Gap Between R and Python: Introducing a select Method for Python's Pandas

For data analysts and data scientists who have transitioned from R to Python, one of the most noticeable differences lies in the way these languages handle DataFrame operations. R users, especially those familiar with the dplyr package, often find themselves missing the simplicity and intuitiveness of R’s select function when they switch to Python’s pandas. This article explores why Python lacks a direct equivalent of R’s select function, the limitations of using the available alternatives, and how a custom select method can make the transition smoother while enhancing the efficiency of pandas method chaining....

August 10, 2024 · 6 min · 1272 words · Maddy

Exploring Python's dir(), getattr(), and setattr() with simple objects

Python provides powerful built-in functions like dir(), getattr(), and setattr() that allow you to explore, access, and modify object attributes dynamically. These tools are particularly useful when working with custom objects, debugging, or when your code needs to interact with objects in a flexible way. In this article, we’ll walk through these functions using a simple custom class, and demonstrate their practical applications. Introducing a Simple Custom Class Let’s start by defining a basic class that we’ll use throughout this article:...

August 8, 2024 · 4 min · 739 words · Maddy

Fine control properties in Seaborn object interface

Seaborn has long been a go-to tool for statistical plotting in Python. While it may not be as powerful as R’s ggplot2, it’s widely used due to the lack of better alternatives. However, this is changing with the rise of excellent packages like plotnine. One of the biggest drawbacks of Seaborn, in my opinion, has been its inconsistent syntax, which contrasts with the predictable and intuitive syntax of ggplot2 and plotnine, both based on the grammar of graphics....

August 6, 2024 · 3 min · 587 words · Maddy