CodeX
Published in

CodeX

Python Development Setup for Data Scientists in 2022

Photo by ian dooley on Unsplash
  • use both Mac and Windows (WSL)
  • deploy code to cloud services like Google Cloud Run
  • handle several projects simultaneously
  • manage environmental setting by Git

Table of Content

  • Visual Studio Code(vscode); free and useful editor
  • Peacock; color schema manager [Recommended]
  • Rainbow CSV; coloring CSV file
  • autoDocstring; document generator
  • pyenv; version manager
  • Poetry; powerful package manager [Recommended]
  • Black, Flake8, isort, and Mypy; formatter and linter

Visual Studio Code(vscode); free and useful editor

https://code.visualstudio.com/

Jupyter Notebook in vscode (Image by author)

Peacock; color schema manager

  • "Ctrl(Command) + Shift + P" in vscode
  • type "Peacock: Change to a Favorite Color"
  • select your favorite one
Select your favorite color (Image by author)
You can distinguish the project you want to work on (Image by author)
You can control the color by Git (Image by author)

Rainbow CSV; coloring CSV file

https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv

Colorizing dataset (Image by author)

autoDocstring; document generator

https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring

type double quotation three times, then the document will be generated (Image by author)

pyenv; version manager

https://github.com/pyenv/pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
pyenv install 3.9.11
pyenv local 3.9.11
pyenv generates version file (Image by author)

Poetry; a powerful package manager

Former defines only pandas and Python itself (Image by author)
Latter describes all the packages that are used by pandas (Image by author)
$ pip install poetry # install Poetry
$ poetry config virtualenvs.in-project true --local # generate venv in working directory
$ poetry init # initial settings of Poetry
$ poetry add pandas # install package e.g. pandas
$ poetry shell # launch virtual environment
select poetry virtual environment (Image by author)

Black, Flake8, isort, and Mypy; formatter and linter

poetry add -D black flake8 isort mypy
"python.formatting.provider": "black",
"python.linting.flake8Enabled": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"python.linting.mypyEnabled": true,

Conclusion

I've introduced several valuable tools for data scientists to set up a Python environment. I uploaded sources in this repository(https://github.com/koyaaarr/python-setup).

--

--

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store