How to use Python on iPad

Learn how to use an iPad to create Python scripts

Jose Manu (CodingFun)
Towards Data Science

--

For all of you who have been reading my blog on Python for Finance and watching my videos, I wanted to share with you how to code in Python using an iPad.

Python in iPad
Photo by bongkarn thanyakij from Pexels

Why Python for iPad?

Some of you may be wondering why should I change my laptop for my iPad in order to code? From my point of view, I do not see the iPad replacing the laptop for coding purposes. At least not in the short term. However, it can be used as a great complement to the laptop for coding purposes.

For example, imagine that you are going for a weekend to visit your family somewhere in the lake and you do not feel like taking the computer and charger with you. In that case, if you want to keep coding during the weekend getaway, the only option left is to carry on an iPad.

How to code using Python on an iPad?

From my experience, the best way that I have found so far to use Python on an iPad is through Google Colab. It is a free tool available to everyone having a Gmail/Google account.

Google Colab offers the same functionality as Jupyter notebook. Colab allows you to write and execute Python in your browser and the main advantages are:

  • There is not pre set-up required. It comes with plenty of packages pre-installed. I.e. Pandas, Numpy, TensorFlow, Scikit-learn, Matplotlib and many others. We can use them simply by importing the packages.
  • Scripts are available in all devices. I.e. Same scripts can be accessed and edited in laptop and iPad.
  • Free access to GPUs.
  • The code and script can be very easily shared with others. The script created can be uploaded into Github or downloaded to the local disk as a .py extension.
  • The best of all is that it is totally for free and enable us to code with Python on iPad.

To sum up, I see Google Colab as great tool to use it for financial analysis or any other data science projects. All of my articles posted in Medium are done using Google Colab or Jupyter Notebook. Which means that they all can be replicated using an iPad.

How to set up Google Colab?

In order to start using Python on iPad, we need to have a Google drive account. Google Drive offers free cloud storage for personal use. You can create a free account here.

Once an account is created, below are the steps to follow in order to start coding in iPad:

  1. Login using the browser to Google Drive in your iPad. Then, create a new Colab document by clicking on New:

2. Select More and Google Colaboratory. If you do note see Google Colaboratory in the list, click on Connect more apps in order to install it into your Google Drive.

3. A new Google Colab document will open where we will be able to add our code or text:

4. Below are the main parts of a document. Click on 1 to rename the document. 2 and 3 let you add new cells for coding or simple text edition. 4 is the cell where we can enter the Python code. Once the script is ready, click on 5 to run the code in that cell. Finally, save or download your code by using the tool bar (6).

5. Start typing your code. Below in as simple example to create a Pandas DataFrame:

6. Run the cell to execute the code by clicking in the play button. The outcome is shown below the cell:

Wrapping Up

As we have seen, it is super easy to start to use Python on an iPad. However, I do not see my iPad replacing my laptop for my Python projects for two reasons.:

  • First and more important, it is super inefficient for me to write code using the iPad onscreen keyboard. I am slower and more prone to errors than using a normal keyboard. I will share my experience in a later post if by using the iPad Magic Keyboard the experience improves.
  • And the second reason is the smaller screen in my iPad compared to my laptop or desktop computer.

Nevertheless, from time to time, specially when I have to travel, I use my iPad for Python coding and it works as if I were coding in a computer. Feel free to leave a comment with your experience on coding with iPad and which app are you using for it.

I also have a short Youtube video on how to code in Python using an iPad:

How to code in Python using an iPad

Originally published at https://codingandfun.com on May 24, 2020.

--

--

Python for Finance. Learn step by step how to automate cool financial analysis tools.