Last Updated on May 28, 2023 by mishou

I. Running code on Google Colaboratory

1. Use sample data sets

You can find sample data sets on Google Colaboratory. You can also get some data sets from Seaborn, which is a library for creating charts.

sample data

2. Use “( )” and “\”

Using parentheses and slashes makes the code easy to read.

Example 1

The following code is not friendly to read:

df.filter(['english', 'nationality']).groupby(by='nationality').mean().sort_values(by='english', ascending=False).plot.bar()

Use parentheses:

chart on google colaboratory

Example 2

The following code is not friendly to read:

df.sketch.howto('group by nationality and show the averages of english by nationality and create bar charts of the averages using pandas.')

Use slashes to break lines:

texts broken by "\" on Google Colab

II. Running code on your computer

1. Use Pipenv

I recommend you use Pyenv to manage Python versions and create virtual environments. You can install libraries by running simple commands like Pip. For example, you can install Pandas by running ‘pipenv install pandas‘. You can learn about Pipenv here:

https://github.com/pypa/pipenv#usage

https://towardsdatascience.com/virtual-environments-for-data-science-running-python-and-jupyter-with-pipenv-c6cb6c44a405

Using Pipenv

1.Make a new directory for your project and move to the directory by running the following command:

mkdir PROJECTNAME && cd PROJECTNAME

2.Create a virtual environment for the project by running the following command:

pipenv --python 3.9

3.Activate the virtual environment by running the following command:

pipenv shell

4.Install a library
pipenv install pandas

    Using pipenv

    To be continued.

    By mishou

    Leave a Reply

    Your email address will not be published. Required fields are marked *