Skip to content
Advertisement

Pandas cleaner syntax

I would like to replace the following syntax with a cleaner, chained syntax – perhaps using .pipe (similar to dplyr library in R):

Sample dataset:

JavaScript

Code to replace by piping:

JavaScript

Expected output:

JavaScript

Advertisement

Answer

Here are two elegant ways to get your output:

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement