GithubHelp home page GithubHelp logo

learning_python's Introduction

README

Python is a general-purpose programming language that is very popular. I have wanted to learn Python for a long time but have put it off because I could get everything done in Perl and R. However, recently I've been working with Snakemake, which is a workflow management system based on Python, and realised that knowing Python would help me use the tool better. In addition, a lot of my colleagues are using Python, so it helps to be able read and write Python.

The Jupyter Notebook

The notebook formerly known as the IPython Notebook has also been on my list of things to learn. It serves as an interactive session for interweaving code and plain text. Just install Anaconda for your operating system and that will install Jupyter Notebook.

wget -c https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh
bash Anaconda3-5.2.0-Linux-x86_64.sh
source ~/.bashrc

After installation, run jupyter notebook to host an interactive session. I will use Jupyter notebooks to keep track of my Python code. Below are some useful links:

Shortcuts

Some shortcuts:

  • The notebook has a command and edit mode; press escape to enter command mode and press enter to enter edit mode.
  • In command mode, press m to change a cell to Markdown and y to change a cell to code
  • Control+enter to execute code
  • a and b to insert a cell above and below, respectively
  • Vim shortcuts like dd and hjkl work in command mode

Docker

Jupyter Docker Stacks are a set of ready-to-run Docker images containing Jupyter applications and interactive computing tools. Use jupyter/scipy-notebook, which includes popular packages from the scientific Python ecosystem.

docker pull jupyter/scipy-notebook:latest

Running a container from this GitHub repository to access the notebook directory.

docker run -v "$PWD":/home/jovyan/work -p 8888:8888 jupyter/scipy-notebook:latest

Reticulate

The reticulate package provides a comprehensive set of tools for interoperability between Python and R. Reticulate embeds a Python session within your R session, enabling seamless, high-performance interoperability.

install.packages("reticulate")
library(reticulate)
use_python("/anaconda3/bin/python")

Check configurations

# check if Python is available
py_available()

# check Python config
py_config()

# check if module is available
py_module_available("umap")

# check version of Python to use with reticulate
# and location of module
py_discover_config("umap")

Using Python in R Markdown

```{python}
import sys
print(sys.version)
```

Links

  • Perl to Python phrasebook for those coming from Perl and wanting to learn Python

learning_python's People

Contributors

davetang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.