DEV Community

Cover image for Data Science: Best Vscode settings
Azad Kshitij
Azad Kshitij

Posted on

Data Science: Best Vscode settings

VS code has become the tool for any programming project and data science is one of them. Most data scientists like to use jupyter notebook or jupyter lab but what they don't know is VS Code support jupyter notebook and you can do much more than just use jupyter notebook. one of the best feature of vscode for data science is Interactive python window will talk about that later, lets talk about some other features.

1. IntelliSense

IntelliSense is a general term for various code editing features including: code completion, parameter info, quick info, and member lists. IntelliSense features are sometimes called by other names such as "code completion", "content assist", and "code hinting."

IntelliSense

When we install python extension for vscode it comes with IntelliSense and it works as intended. You can improve IntelliSense with type annotation in your project.

IntelliSense with type annotation

As you can see in above image there is no suggestions for the name parameter but as soon as we define type of parameter vscode will show all the available methods related to the datatype (below image).

suggestions for the name parameter

2. Indent (Space vs Tabs)

At the end of the day, tabs versus spaces is truly a matter of preference, however the tab is still the character specifically designed for indentation, and using one tab character per indentation level instead of 2 or 4 spaces will use less disk space / memory / compiler resources and the like.

It depends on individual, I prefer tab and set it as 2 space (2 column) width as it occupies less space and I only have to key only one time and every stroke matters. To change indent size in vscode follow below steps...

Tabs

2 tabs

3. Text Warp

Most of us don't prefer text to run off the screen. To toggle wrapping on or off on a per-file basis, simply press ALT + Z . If you almost never want to turn text-wrapping off, you can make it the default. Inside settings.json, simply paste in the following code, and your text will wrap by default:

{ "editor.wordWrap": "on" }
Enter fullscreen mode Exit fullscreen mode

4. Evaluate Math Expression

You know vscode have inbuild calculator? You can evaluate basic math operation. Just select the expression, press ctrl+shift+p and search for "Evaluate and you will find the option".

Evaluate Math Expression

5. Format on Save

Install black, a python formatter that will help us follow a similar formatting for all our data science projects. command:

pip install black
Enter fullscreen mode Exit fullscreen mode

Open your VSCode settings, by going 'Code -> Preferences -> Settings'. Search for "python formatting provider" and select "black" from the dropdown menu:

Code -> Preferences -> Settings

In the settings, search for "format on save" and enable the "Editor: Format on Save" option:

Editor: Format on Save

6. Snippets

You can install extensions for snippets but you can also define your own snippets. With this features you can type few character to type repeated code like imports statements, plotting functions etc.

Snippets

7. Interactive Python Window

VSCode support interactive python window, where you can run python code just like jupyter notebook but even better as your main code is stored in a single python file. This is a very important and productive features for data scientist. For this to work you need to change the setting with...

"jupyter.sendSelectionToInteractiveWindow": true // <---- Very Important
Enter fullscreen mode Exit fullscreen mode

Interactive Python Window

8. Remote access to VMs

Odds are that you’ll run code in a server, a virtual machine or some other hardware that you might want to connect to via SSH. Fortunately, you can connect to any of them and still carry on using your local VS Code installation, by using the Remote SSH extension.

9. CSV

As a data scientists you have to deal with a lot of file types that stores the data, CSV is the most famous file type to store huge amount of data. As CSV is a txt file so you can open it directly in vscode but to make it more usable and readable we can use extensions such as...

  1. Rainbow CSV which will provide highlighting for your csv file..

Rainbow CSV

  1. Edit csv which has a excel like UI to edit and update your csv file.

Edit csv

As the article is getting longer we will talk about some more settings in future articles so make sure to follow the series to not miss any updates. If you have anything to say comment down below I'm new to blog writing so any type of feedback is appreciated Thanks.

Top comments (0)