How to Use Datasnips & Make Your Data Science Life Easier
WHAT IS DATASNIPS?
Datasnips is a platform for you to create, save and organise data science and engineering code snippets while also being able to discover those created by other users.
Code snippets on Datasnips are usually short and can be used as they are or as templates to be copied straight into your scripts and notebooks whenever you're working on a project or studying. It can also be used to save examples and descriptions about methods and concepts you find useful to remember and reference.
The snippets you create (along with any you bookmark from other users) are organised inside your own snippet library, structured by language and by use (Data Preprocessing, Visualisation & EDA, NLP etc). This enables you to quickly find code snippets you've created before or have saved for furture reference rather than spending time frustratingly searching the web for what you need.
You can make your snippets public so other users can find, use and upvote them or you can make them private so only you have access. At the same time you can search Datasnips for useful snippets from other users and add them to your library alongside those you create yourself.
Here's how to get started:
CREATING CODE SNIPPETS
To start with you will need to go to Datasnips.com and sign up. When you first sign up you will find your snippet libray on the left hand side where there are headings for Python, R, SQL and Terminal but to start with your library will be empty.
To create a code snippet simply click on the yellow "Create Snippet" button at the top of your snippet library.
This will take you to the create snippet form.
As an example, we are going to create a simple code snippet that demonstrates how to read a csv file into a pandas dataframe. To start with let's give the snippet a title. This will be what is listed in your snippet library and also what others will see when searching Datasnips.
Next we'll add some information that will allow the snippet to be organised in your library and also aid in searching for the snippet. First we'll select the language from the drop down list which in this case is Python.
Once we've selected a language we can then categorise our snippet. There are number of options available from the dropdown menu but what you select here will dictate which subheading in your library the snippet sits under.
There will sometimes be more than one category that makes sense for a snippet so pick which you think is most relevant.
For our snippet we are going to pick "Import and Export".
It's important to note that you need to select a language before a category for your snippet as different languages have different categories that can be chosen.
You can also add optinal tags to your snippet which can be used to help make your snippet easier to find. You can add multiple tags by seperating them by commas. For our snippet we are going to add "csv" and "pandas" as our tags.
Next we'll add some notes to our snippet. This is where you can provide a description about what the snippet does, some extra detail or anything else you think is important to include.
Now we've provided all the information about the snippet, it's time to include the code itself. Your code snippet can be as simple as a single line or as many lines of code as you need.
Finally we have the option to add an image and whether to keep the snippet public or make it private so that you are the only one who can view the snippet. Adding images are useful for providing an image of the snippet's ouput, especially if the output is a visualisation.
Once you're happy with your snippet you can add it to Datasnips using the Submit button. Your code snippet will then be created.
The snippet will appear in your snippet library and whenever you need the code you can simply locate it in your library under the language and category the snippet was given.
If later you want to make changes to your code snippet, you can simply click the "Edit `Snippet" button in the top right of the snippet. This will take you to the Edit Snippet form where you can make any changes you want.
DISCOVERING SNIPPETS FROM OTHER USERS
On Datasnips not only can you create your own snippets, you can search snippets created by others and add those to your library. There are a few ways to discover snippets created by others.
First, you can look through the latest snippets submitted to Datasnips by clicking Latest Snippets and looking through the list of recently added snippets.
You can also click on the language or category links on the right side nav.
Finally, you can search by tags using the search box located on the right hand side.
Once you find a snippet that's useful you can upvote it and also bookmark the snippet which will add it to your snippet library alongside the ones you've created yourself.
Datasnips is a simple tool to keep useful code snippets easily accessible and save you time looking through old scripts or searching the web for code examples when you're working on projects or studying. By maintaining a snippet library through bookmarking useful snippets from others or creating your own from what you develop in your own projects, you'll gradually build up an important tool for becoming a more productive and efficient data scientist, analyst or engineer.