From R to Python: A Gentle Introduction

Federica Gazzelloni
R-Ladies Rome

2025-04-27

Welcome Everyone!

Disclaimer

This talk is recorded and will be posted on Youtube @rladiesrome

Please remember that all our attendees are expected to adhere to our Code of Conduct ๐Ÿ‘‰ https://rladies.org/coc/


We ensure a safe, inclusive, and harassment-free space for learning. We are committed to providing a respectful environment where everyone feels welcome to learn, connect, and grow.

Who we are?

rladies_global |>
  filter(city %in% c('Rome'))

R-Ladies Rome is a local chapter of R-Ladies Global dedicated to promoting continous learning in the Open Source Community. Our monthly meetings provide a platform to discuss current trends and hot topics, such as Python ๐Ÿ

Join us!

If youโ€™d like to join our team and contribute to our community, we have a few open positions!


Fill out the form here ๐Ÿ‘‡ https://forms.gle/SkBiab8LhLcehpKu6

Learning Objectives ๐Ÿค“

  • Transition from R to Python
  • Learn how to perform basic tasks in Python
  • Get hands-on with essential Python libraries

Python Quick Takes

๐Ÿ“ฃ Python is a programming language that lets you work quickly and integrate systems more effectively.

  • First appearance in 1991
  • Integrates C, C++, and FORTRAN code (Glue)
  • Defined as an interpreted programming language
  • Provides the global interpreter lock (GIL)

R vs Python ๐Ÿคบ

Use Case R Python
Best for Statistical analysis, data visualization General-purpose programming
Learning curve Intuitive for data analysis and stats Accessible for general programming
Visualization ggplot2 matplotlib
Data handling data.frame, tidyverse pandas, numpy
Machine Learning caret, tidymodels scikit-learn, TensorFlow
Reproducible reporting Quarto, RMarkdown Jupyter Notebooks, Quarto
Community Strong in academia and research Strong in industry and web development

Essential Python Libraries๐Ÿ“š

  • NumPy (Numerical Python)
  • pandas (high-level data structures and functions)
  • matplotlib (plots and other two-dimensional data visualizations)
  • SciPy (collection of scientific packages)
  • scikit-learn (machine learning toolkit)
  • statsmodels (statistical modeling)

Install Python

  • Download: https://www.python.org/downloads/
  • Install the latest version of Python3
  • Install an IDE (Integrated Development Environment):
    • VSCode - Visual Studio Code (IDE)

Hands-on: Python Basics

Install Python libraries

  • Use pip (Python package manager) to install libraries
  • Open a terminal and type:
python3 -m pip install pandas
python3 -m pip install matplotlib
python3 -m pip install numpy

Load libraries

  • Use import to load libraries
  • Use as to give a library an alias
import pandas as pd

Use a function from a library

data.frame(a = c(1, 2, 3, 4),
           b = c(5, 6, 7, 8))
pd.DataFrame({'a': [1,2,3,4], 
              'b': [5,6,7,8]})

Resources