Manish Barnwal

...just another human

Handling errors with try-catch in Python

In the previous post I discuss about how to convert a string to date format in Python. I was working on similar idea today. I had a column of object type which was string of dates. The column name is 'signed_up_at' and I wanted to convert it to date format ...

Working with dates in Python

from datetime import datetime

To convert a string to date:

`datetime.strptime('string', 'format_of_the_string')``

d1 = datetime.strptime('2017-02-02', '%Y-%m-%d')

`d2 = datetime.strptime('2018-06-17', '%Y-%m-%d')``

Find the number of days between two dates `delta = d2 - d1 delta.days ``

Difference between today and some date today = datetime.today ...

git and github for data scientists

It has been close to a year since I shifted to a start-up which incidentally got acquired after a month of my joining. Before this I used to work at WalmartLabs where we always wanted to use a version control system like git but it never took off properly. Now ...

Creating a virtual environment in Python

I was trying to get a virtual environment set up on Python 3 using mkvirtualenv but somehow the virtual environment was getting created on Python 2.7 (my system python).

If you already know about virtual environments and why they are useful, you may skip the next two paragraphs. I ...

Common docker commands

Photo of docker

I recently got to know about dockers. And I love it. For those who don't know what dockers are. Here it is. Dockers help in software ...

Markdown commands I use frequently

This post is aimed to capture the list of commands I use frequently while writing a post for this site in Markdown. You can write a post both in Markdown format and in HTML format. Markdown is preferred when you want to have a free-flow writing style. HTML is used ...

Improve runtime of Random Forest in R

There are two ways one can write the code to train a random forest model in R. Both the ways are listed below.

A normal and frequent way of writing the command to train the random forest model is something like this.

rfModel <- randomForest(Survived~. , data = trainSample[, -c(6, 8 ...

How to install a package of a particular version in R

I recently tried installing caret package in R using

install.packages('caret', dependencies=T)

Normally this installation of package works and I continue to work with the functions associated with the package. When I tried including the package using

library(caret)

I got the following error.

Error in loadNamespace(j ...

Shell commands come in handy for a data scientist

I am no expert of shell commands. I have been using them for quite some time and thought I give an attempt to list down the most common commands. I am writing these mostly from the perspective of a data-science guy. Let us get started.

I will use the file- ...