VS Code Speed Hack for Data Science
Key Takeaways
Configures VS Code for data science workflows using Python snippets and extensions
Full Transcript
so this week I learned how to do this what you're looking at here is a snippet and you can set that up in Visual Studio code and this can really improve your workflow so let me show you how it works so Snippets are basically little code templates that you can store in Visual Studio code and then you can call upon them with a certain prefix that you identify to start creating a snippet for your data science project all you have to do is open up the command palette by hitting command shift B then typing Snippets and then you have the option to insert or configure the user Snippets so first go to the configure user Snippets and then we can set a new Global snippet file and we can give it a name example Snippets so I already have a snippet that I started working on so this will be a snippet to create a bundles data frame and it will also import numpy SMP and bundles SPD so these are your typical data science Imports and if you've been working in data science for a while you've probably typed these import statements out hundreds of times if not thousands so this can raise really save some time down the line now this is a very basic snippet but of course the sky is the limit here so now it's up to us as a data scientist to get creative and to start creating Snippets for certain pieces of code that we often reuse so this is my own Snippets file called data science and I currently have four Snippets in here so let me show you how this works so this one over here to create bundles data frame is the one we were just looking at now if I go back to a file an empty file and start from scratch what we can now do remember we specify the prefix PD I can now type PD and then intellisense will pop up with some options that we can choose from here so other prefixes for PD that might pop up here are related to other features within Visual Studio code but you can recognize your snippet from the name you gave it so create bonus data frame then you can either hit enter or depth to complete it and boom we have our import statements and we can specify a path to read the data frame and what makes this even better is that we can add tab stops and placeholders so notice how my cursor is already between the quotes over here and I can immediately start to type above so for example we can go to raw and then select my data over here and then run the Imports and boom we have our data frame so how this works is you can specify tab stops and placeholders with a dollar sign followed by a number so one would be your first parameter then two would be your second parameter and zero denotes the final cursor position so basically how this works if you use these step stops in your Snippets then after inserting snippet you will start at position one then you can type your variable then you can hit a hit Tab and you can go to variable 2 and then eventually you go to position 0 if you've indicated it and what's even more awesome is that you can use the indicator for one multiple times and then when you start typing it will update all the references with dollar one so for example if you want to type DF or data everywhere that you have dollar sign 1 will be updated at once let me show you okay so let's create a new snippet and make it a bit more complex so I can show you how the depth stops and placeholders work so for example let's create a snippet to create a trained test split so we'll call this train test split and then in the body we'll import these Snippets over here so we import the train test plate from sklearn.model selection we Define our data frame our targets and then we Define our X and Y and then we split the data and what I forgot to mention is that you can also specify the scope so in this case Python and this ensures that the Snippets using the prefix will only trigger when you're working in a python file so this is convenient for example when you use different code language so for example you work on HTML CSS project but also python or JavaScript for example and you can create separate Snippets for each language and defining the scope will ensure that you keep everything separate and make sure that you don't end up with a trained test split in your HTML file for example and the final step is to change the prefix so let's call this TTS for train test split let's save this this and now let's see in a new file how fast we can load the data frame and then create a trained test split for it so we'll start off by running PD and then create our data frame then we link to our data let's run this so now we have our data frame and then we run TTS train test splits and then look how our cursor is now placed at depth stop one for the F so we say the F in this case then we do tap and we go to the Target and I know that the target for this data set is rentals so we'll type in rentals then let's run everything with X train and we have an X test so nice 80 20 split see how easy that was and using Snippets like this can not only save you time by not having to type everything out it also saves Time by not having to look everything up for example on stack Overflow or documentation so if you don't exactly remember how to specify a trained test split you would maybe then go to Google and then you would search Escalon train test split because you kind of know how it works but you don't remember the exact syntax and then you go here and then oh it's like this and then you have to copy everything from here that's not the case anymore you just have to remember your snippet prefix so TTS train test split boom there it is now of course this is just the beginning in the sky is the limit here I would really recommend to look into the documentation about the snippets on the visual studio code webpage I will link it in the description because there are also some really powerful variables that you can use so selected the select the text current line stuff like this and you can use that to input the variables like that and also I didn't cover that but you can use placeholders using the notation over here so there's a lot to cover here but the best way to learn this is to just get started with it and try to come up with some of your own Snippets to so basically to build a file like this and then save it and then test it so another cool one that I have is I do a hashtag for uh for commenting I can insert a header like this and then for example we say this is loading the data and like this we can create nice headers so it still works like this I can comment stuff like this but I can also do a hashtag and then hit enter and then I have a header file and then for example we would now like process the data so that is another cool snippet and I only just started playing around with this another cool thing that I have in here that I definitely want to play more with is to create Snippets for certain models so this would be a simple linear regression with prefix SK from scikit-learn and then linear regression so if I go in here and then do sklr then hit enter you have to set up to train a basic linear regression model with test strain split defining the model all the Imports as well we can just move this up like this so yeah overall really convenient method and something that was new for me I think this is more common in software development but most data scientists come from working in Jupiter labs and Jupiter notebook at least that's what I started out with and earlier this year I completely switched to official Studio code and I'm loving it so far it's just way faster in my opinion and it's had so much nice features that can improve your productivity and your workflow and and using Snippets is one of them so that's what I wanted to share in today's video because I only just found out about this feature recently and I'm loving it so far I'm definitely going to explore the feature and start to create more Snippets for my data science Library as always thanks for watching and if you want to learn more about working with data then subscribe to the channel and check out some of the other videos that will pop up on the screen right now [Music]
Original Description
In this video, I will show you how to use python snippets in Visual Studio Code. These can really speed up your data science workflow and save you a lot of time.
Timestamp
00:00 Introduction
00:10 What are snippets
00:19 How to create snippets
01:33 Inserting snippets
02:17 Tabstops and placeholders
03:03 Create a train/test snippet
05:10 Final thoughts
Snippets in VS Code
- https://code.visualstudio.com/docs/editor/userdefinedsnippets
Let's Connect
- Instagram | https://instagram.com/daveebbelaar
- LinkedIn | https://linkedin.com/in/daveebbelaar
- Twitter | https://twitter.com/daveebbelaar
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Dave Ebbelaar · Dave Ebbelaar · 16 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
▶
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How to Install Homebrew on Mac (Getting Started)
Dave Ebbelaar
How to Install Python on Mac (Homebrew)
Dave Ebbelaar
How to Install Anaconda on Mac (Getting Started)
Dave Ebbelaar
How to Set up VS Code for Data Science & AI
Dave Ebbelaar
How to Use Git in VS Code for Data Science
Dave Ebbelaar
Data Science Desk Setup to Maximize Productivity
Dave Ebbelaar
THIS Is How I Write Clean Data Science Code EVERY TIME
Dave Ebbelaar
Data Science Tutorial - Project Structure
Dave Ebbelaar
Changing rcParams for Better Data Science Plots | Matplotlib Tutorial
Dave Ebbelaar
How to Read Excel Files with Python (Pandas Tutorial)
Dave Ebbelaar
My Data Science Journey (Zero to Freelance)
Dave Ebbelaar
How I Automate Data Visualization in Python
Dave Ebbelaar
16 Apps I Use Daily as a Data Scientist
Dave Ebbelaar
How to Manage Conda Environments for Data Science
Dave Ebbelaar
How to Export Machine Learning Models in Python
Dave Ebbelaar
VS Code Speed Hack for Data Science
Dave Ebbelaar
17 VS Code Tips That Will Change Your Data Science Workflow
Dave Ebbelaar
How to Predict the Future with Python (Forecasting Tutorial)
Dave Ebbelaar
How to Use Python Environment Variables
Dave Ebbelaar
7 Data Science Tips for Beginners in 2023
Dave Ebbelaar
How to Effectively Use the Data Science Lifecycle
Dave Ebbelaar
Full Machine Learning Project — Coding a Fitness Tracker with Python (Part 1)
Dave Ebbelaar
Full Machine Learning Project — Processing Raw Data (Part 2)
Dave Ebbelaar
Full Machine Learning Project — Data Visualization with Matplotlib (Part 3)
Dave Ebbelaar
This Will Change Data Science as We Know It (ChatGPT)
Dave Ebbelaar
Full Machine Learning Project — Detecting Outliers in Sensor Data (Part 4)
Dave Ebbelaar
Full Machine Learning Project — Low-pass Filter & Principal Component Analysis (Part 5a)
Dave Ebbelaar
Full Machine Learning Project — Fourier Transformation & Clustering (Part 5b)
Dave Ebbelaar
Full Machine Learning Project — Predictive Modelling (Part 6)
Dave Ebbelaar
Automate Machine Learning with ChatGPT
Dave Ebbelaar
Scraping Web Datasets for Data Science Projects
Dave Ebbelaar
Full Machine Learning Project — Counting Repetitions (Part 7)
Dave Ebbelaar
How to Use GitHub Copilot for Data Science (Python + VS Code)
Dave Ebbelaar
Every Beginner Data Scientist Should Understand This
Dave Ebbelaar
Revealing My New AI-Powered Data Science Workflow
Dave Ebbelaar
Auto-GPT Tutorial - Create Your Personal AI Assistant 🦾
Dave Ebbelaar
Build Your Own Auto-GPT Apps with LangChain (Python Tutorial)
Dave Ebbelaar
Building Slack AI Assistants with Python & LangChain
Dave Ebbelaar
ChatGPT Code Interpreter - Goodbye Data Analysts?
Dave Ebbelaar
How to Deploy AI Apps to the Cloud with Flask & Azure
Dave Ebbelaar
How to Build an AI Document Chatbot in 10 Minutes
Dave Ebbelaar
Is Falcon LLM the OpenAI Alternative? An Experimental Setup with LangChain
Dave Ebbelaar
GPT Engineer... Generate an entire codebase with one prompt
Dave Ebbelaar
Pandas DataFrame Agent... the future of data analysis?
Dave Ebbelaar
OpenAI Function Calling - Full Beginner Tutorial
Dave Ebbelaar
How to use ChatGPT's new “Code Interpreter” feature
Dave Ebbelaar
LangChain just launched their new "LangSmith" platform
Dave Ebbelaar
How I'd Learn AI (if I could start over)
Dave Ebbelaar
I Used AI To Scrape The Web & Write PDF Reports
Dave Ebbelaar
LangSmith Tutorial - LLM Evaluation for Beginners
Dave Ebbelaar
7 Lessons for New AI Engineers - Beginner’s Guide
Dave Ebbelaar
The Rise of the "New-Age" Machine Learning Engineer
Dave Ebbelaar
OpenAI Assistants Tutorial for Beginners
Dave Ebbelaar
How To Connect OpenAI To WhatsApp (Python Tutorial)
Dave Ebbelaar
How to Build Chatbot Interfaces with Python
Dave Ebbelaar
PostgreSQL as VectorDB - Beginner Tutorial
Dave Ebbelaar
My MacBook Setup (as a coder & business owner)
Dave Ebbelaar
Easiest Way to Connect AI Chatbots to WhatsApp
Dave Ebbelaar
ClickUp Tutorial - What Is ClickUp Brain? 🧠
Dave Ebbelaar
My Development Workflow for Data & AI Projects
Dave Ebbelaar
More on: AI Workflow Automation
View skill →Related Reads
📰
📰
📰
📰
Why AI Increases the Need for Platform Engineering
Dev.to AI
AI for CS Assignments: How I Survive Technical Writing (Without Completely Dreading It)
Dev.to AI
I built RepoLens: a repo docs, diagrams, security report & AI chat, from one knowledge graph
Dev.to · OnamSharma
Can we use AI for academic writing? It depends:
Medium · AI
Chapters (7)
Introduction
0:10
What are snippets
0:19
How to create snippets
1:33
Inserting snippets
2:17
Tabstops and placeholders
3:03
Create a train/test snippet
5:10
Final thoughts
🎓
Tutor Explanation
DeepCamp AI