Python: Writing Pandas in a dplyr-like way ver. 2

Last Updated on October 17, 2021 by shibatau

I.What will you learn?

We will learn Pandas from a new perspective according to the post:

Joshua Ebner, A Quick Introduction to the Python Pandas Package

I learned R before I learned Python like Joshua Ebner. I was accustomed to using dplyr and felt great admiration for tidyverse. And I wished I could have written Pandas codes in the same way as Pipes in R.

Now I’m very happy to learn how to use Pandas’ multiple functions in series, on separate lines from the above post. We will write a more readable scripts with parentheses and methods shown here.

II.Sample

Data: https://pastebin.com/raw/cSZ8pYWh

All scripts: https://colab.research.google.com/drive/1cxHvddpxRYOFA-YsD4qPV4F0Qol7NLgc?usp=sharing

1.

Please compare [2] with [3] in the image below. Isn’t [3] is much easier to read and understand?

2.

These scripts produce the same result but the last one is the easiest to read.

To be continued.

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.