Python & Julia port of codes in excellent R books

Overview

X4DS

This repo is a collection of

Python & Julia port of codes in the following excellent R books:

Python Stack Julia Stack
Language
Version
v3.9 v1.7
Data
Processing
  • Pandas
  • DataFrames
  • Visualization
  • Matplotlib
  • Seaborn
  • MakiE
  • AlgebraOfGraphics
  • Machine
    Learning
  • Scikit-Learn
  • MLJ
  • Probablistic
    Programming
  • PyMC
  • Turing
  • Code Styles

    2.1. Basics

    • prefer enumerate() over range(len())
    xs = range(3)
    
    # good
    for ind, x in enumerate(xs):
      print(f'{ind}: {x}')
    
    # bad
    for i in range(len(xs)):
      print(f'{i}: {xs[i]}')

    2.2. Matplotlib

    including seaborn

    • prefer Axes object over Figure object
    • use constrained_layout=True when draw subplots
    # good
    _, axes = plt.subplots(1, 2, constrained_layout=True)
    axes[0].plot(x1, y1)
    axes[1].hist(x2, y2)
    
    # bad
    plt.subplot(121)
    plt.plot(x1, y1)
    plt.subplot(122)
    plt.hist(x2, y2)
    • prefer axes.flatten() over plt.subplot() in cases where subplots' data is iterable
    • prefer zip() or enumerate() over range() for iterable objects
    # good
    _, ax = plt.subplots(2, 2, figsize=[12,8],constrained_layout=True)
    
    for ax, x, y in zip(axes.flatten(), xs, ys):
      ax.plot(x, y)
    
    # bad
    for i in range(4):
      ax = plt.subplot(2, 2, i+1)
      ax.plot(x[i], y[i])
    • prefer set() method over set_*() method
    # good
    ax.set(xlabel='x', ylabel='y')
    
    # bad
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    • Prefer despine() over ax.spines[*].set_visible()
    # good
    sns.despine()
    
    # bad
    ax.spines["top"].set_visible(False)
    ax.spines["bottom"].set_visible(False)
    ax.spines["right"].set_visible(False)
    ax.spines["left"].set_visible(False)

    2.3. Pandas

    • prefer df['col'] over df.col
    # good
    movies['duration']
    
    # bad
    movies.duration
    • prefer df.query over df[] or df.loc[] in simple-selection
    # good
    movies.query('duration >= 200')
    
    # bad
    movies[movies['duration'] >= 200]
    movies.loc[movies['duration'] >= 200, :]
    • prefer df.loc and df.iloc over df[] in multiple-selection
    # good
    movies.loc[movies['duration'] >= 200, 'genre']
    movies.iloc[0:2, :]
    
    # bad
    movies[movies['duration'] >= 200].genre
    movies[0:2]

    LaTeX Styles

    Multiple lines

    Reduce the use of begin{array}...end{array}

    • equations: begin{aligned}...end{aligned}
    $$
    \begin{aligned}
    y_1 = x^2 + 2*x \\
    y_2 = x^3 + x
    \end{aligned}
    $$
    • equations with conditions: begin{cases}...end{cases}
    $$
    \begin{cases}
    y = x^2 + 2*x & x > 0 \\
    y = x^3 + x & x ≤ 0
    \end{cases}
    $$
    • matrix: begin{matrix}...end{matrix}
    $$
    \begin{vmatrix}
      a + a^′ & b + b^′ \\ c & d
      \end{vmatrix}= \begin{vmatrix}
      a & b \\ c & d
      \end{vmatrix} + \begin{vmatrix}
      a^′ & b^′ \\ c & d
    \end{vmatrix}
    $$

    Brackets

    • prefer \Bigg...\Bigg over \left...\right
    $$
    A\Bigg[v_1\ v_2\ \ v_r\Bigg]
    $$
    • prefer \underset{}{} over \underset{}
    $$
    \underset{θ}{\mathrm{argmax}}\ p(x_i|θ)
    $$

    Expressions

    • prefer ^{\top} over ^T for transpose

    $$ 𝐀^⊤ $$

    $$
    𝐀^{\top}
    $$
    • prefer \to over \rightarrow for limit

    $$ \lim_{n → ∞} $$

    $$
    \lim_{n\to \infty}
    $$
    • prefer underset{}{} over \limits_

    $$ \underset{w}{\rm argmin}\ (wx +b) $$

    $$
    \underset{w}{\rm argmin}\ (wx +b)
    $$

    Fonts

    • prefer \mathrm over \mathop or \operatorname
    $$
    θ_{\mathrm{MLE}}=\underset{θ}{\mathrm{argmax}}\ ∑_{i = 1}^{N}\log p(x_i|θ)
    $$

    ISLR

    References

    style <style> table { border-collapse: collapse; text-align: center; } </style>
    Owner
    Gitony
    Gitony
    The Metabolomics Integrator (MINT) is a post-processing tool for liquid chromatography-mass spectrometry (LCMS) based metabolomics.

    MINT (Metabolomics Integrator) The Metabolomics Integrator (MINT) is a post-processing tool for liquid chromatography-mass spectrometry (LCMS) based m

    Sören Wacker 0 May 04, 2022
    An open-source plotting library for statistical data.

    Lets-Plot Lets-Plot is an open-source plotting library for statistical data. It is implemented using the Kotlin programming language. The design of Le

    JetBrains 820 Jan 06, 2023
    Resources for teaching & learning practical data visualization with python.

    Practical Data Visualization with Python Overview All views expressed on this site are my own and do not represent the opinions of any entity with whi

    Paul Jeffries 98 Sep 24, 2022
    Flexitext is a Python library that makes it easier to draw text with multiple styles in Matplotlib

    Flexitext is a Python library that makes it easier to draw text with multiple styles in Matplotlib

    Tomás Capretto 93 Dec 28, 2022
    Runtime analysis of code with plotting

    Runtime analysis of code with plotting A quick comparison among Python, Cython, and the C languages A Programming Assignment regarding the Programming

    Cena Ashoori 2 Dec 24, 2021
    In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas

    CogniPy for Pandas - In-memory Graph Database and Knowledge Graph with Natural Language Interface Whats in the box Reasoning, exploration of RDF/OWL,

    Cognitum Octopus 34 Dec 13, 2022
    Param: Make your Python code clearer and more reliable by declaring Parameters

    Param Param is a library providing Parameters: Python attributes extended to have features such as type and range checking, dynamically generated valu

    HoloViz 304 Jan 07, 2023
    Simple addon for snapping active object to mesh ground

    Snap to Ground Simple addon for snapping active object to mesh ground How to install: install the Python file as an addon use shortcut "D" in 3D view

    Iyad Ahmed 12 Nov 07, 2022
    The official colors of the FAU as matplotlib/seaborn colormaps

    FAU - Colors The official colors of Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU) as matplotlib / seaborn colormaps. We support the old colo

    Machine Learning and Data Analytics Lab FAU 9 Sep 05, 2022
    Project coded in Python using Pandas to look at changes in chase% for batters facing a pitcher first time through the order vs. thrid time

    Project coded in Python using Pandas to look at changes in chase% for batters facing a pitcher first time through the order vs. thrid time

    Jason Kraynak 1 Jan 07, 2022
    Visualizations for machine learning datasets

    Introduction The facets project contains two visualizations for understanding and analyzing machine learning datasets: Facets Overview and Facets Dive

    PAIR code 7.1k Jan 07, 2023
    Geocoding library for Python.

    geopy geopy is a Python client for several popular geocoding web services. geopy makes it easy for Python developers to locate the coordinates of addr

    geopy 3.8k Jan 02, 2023
    The visual framework is designed on the idea of module and implemented by mixin method

    Visual Framework The visual framework is designed on the idea of module and implemented by mixin method. Its biggest feature is the mixins module whic

    LEFTeyes 9 Sep 19, 2022
    Geospatial Data Visualization using PyGMT

    Example script to visualize topographic data, earthquake data, and tomographic data on a map

    Utpal Kumar 2 Jul 30, 2022
    Create SVG drawings from vector geodata files (SHP, geojson, etc).

    SVGIS Create SVG drawings from vector geodata files (SHP, geojson, etc). SVGIS is great for: creating small multiples, combining lots of datasets in a

    Neil Freeman 78 Dec 09, 2022
    Scientific measurement library for instruments, experiments, and live-plotting

    PyMeasure scientific package PyMeasure makes scientific measurements easy to set up and run. The package contains a repository of instrument classes a

    PyMeasure 445 Jan 04, 2023
    Custom Plotly Dash components based on Mantine React Components library

    Dash Mantine Components Dash Mantine Components is a Dash component library based on Mantine React Components Library. It makes it easier to create go

    Snehil Vijay 239 Jan 08, 2023
    A Python function that makes flower plots.

    Flower plot A Python 3.9+ function that makes flower plots. Installation This package requires at least Python 3.9. pip install

    Thomas Roder 4 Jun 12, 2022
    Streamlit component for Let's-Plot visualization library

    streamlit-letsplot This is a work-in-progress, providing a convenience function to plot charts from the Lets-Plot visualization library. Example usage

    Randy Zwitch 9 Nov 03, 2022
    Tweets your monthly GitHub Contributions as Wordle grid

    Tweets your monthly GitHub Contributions as Wordle grid

    Venu Vardhan Reddy Tekula 5 Feb 16, 2022