A quick guide for plotting stylish and professional Venn diagrams using matplotlib-venn

Image for post
Image for post
Both are non-responsive. Source: Author

Last week I was designing some reading material for my Python Class. The lecture topic was Python Sets.

For illustrating some functions, I wanted to plot Venn Diagrams. Yes, the overlapping circle charts that you often find in data presentations.

Source: Giphy

My search for open-source tools for designing professional looking Venn Diagrams lead me to tools like Canva, Meta-Chart, and Creately. While they had appealing designs, none of them had the required elegance and were seldom customizable.

The matplotlib-venn library allows you to completely customize your Venn diagrams, from the size of the circles to border type and line width. Here is a sample plot generated using this library. …


Using Pandas and NumPy for handling missing values in your dataset

A pic which says Data has a better idea.
A pic which says Data has a better idea.
Photo by Franki Chamaki on Unsplash

Last year I was working on a project that dealt with Twitter data. We had around a billion tweets in our database. I needed to clean our data so that we can run some machine learning models on it.

Here is a snapshot of the Dataset:


Learn how to use the range function with the help of different examples

Image for post
Image for post
Photo by Kolleen Gladden on Unsplash.

Range is a built-in Python function that returns a sequence of numbers between a start integer (0 by default) and a stop integer.

We can iterate over the sequence generated by the range function using a for/while loop:

print("Getting a sequence of numbers between 0 and 10")
for i in range(10):
print(i, end =' ')

# Output
# Getting a sequence of numbers between 0 and 10
# 0 1 2 3 4 5 6 7 8 9


Python Beginner

Learning about the Python input function in detail along with its many use-cases

Image for post
Image for post
Photo by Kaitlyn Baker on Unsplash

User input is critical for building interactive programs. Every programming language has its unique implementation of an input interface. C++ has scanf, Java has the Scanner class, and Ruby has gets.

While in most cases, this input stems from the keyboard, other forms like mouse clicks, track-pad, sensors, etc. are also possible.

As always, Python provides a simple framework for getting user input in the form of the input() function.

In this tutorial, we will cover the input() function in detail using a variety of use-cases. We will discuss the several forms in which input can exist and how to parse this input into our required format with the help of code snippets. …


A small tribute to the man who introduced hand-washing and antisepsis to the surgery room

Image for post
Image for post
Photo by CDC on Unsplash

As millions continue to be affected by the scourge of COVID-19, the significance of simple hygiene practices like hand-washing is amplified. CDC has time and again recommended washing hands regularly, stating bluntly that it saves lives.

We are all aware of the importance of washing our hands. Hospitals supply medical practitioners with antiseptic gel before treating patients vulnerable to infection.

One would be hard-pressed to imagine a world where doctors did not sanitize or wash their hands before or after examinations. Yet, we lived in such a world just a little less than 150 years ago.

Until the late 1800s, doctors and health workers did not sanitize or even wash their hands between treating patients, even between surgeries. …


They are seldom useful and don’t look pretty

Image for post
Image for post
Photo by Nadine Shaabana on Unsplash

Coming from a C/C++ background, I am used to seeing a lot of semi-colons ; in code. They are used to represent statement termination.

But, Python does not mandate the use of semi-colons for delimiting statements. Yet, I often come across Python code littered with semi-colons.

Most recently, I was going through a Data Science with Python Course. The instructor was introducing conditional statements and wrote the following piece of code:

temp = 10;if temp <12: print('It is cold'); cold = True;

My reaction: Pure Horror!

Source: Giphy

Semi-colons are used only in atypical situations in Python. So, I prepared a small guide explaining why you shouldn’t use semi-colons in Python and point out the handful exceptions. …


Introducing ways of defining and working with Infinite values in Python

Image for post
Image for post
Photo by Reuben Teo on Unsplash

Many people think that Infinity is just a very large number. But in reality, Infinity is the idea of something being endless and without any bounds.

Since the early ages, mathematicians have gambled with this concept of endlessness. As John Green wrote in his book The Fault in Our Stars,

“Endlessness is a really strange idea in a universe that is defined by its endings.”

Infinity has many desirable properties for algorithmic design. The most popular being:


Useful commands for IPython and Jupyter Notebooks

Image for post
Image for post
Photo by Greg Rakozy on Unsplash

When Python first appeared in 1991, it was seen more as an “at your own risk” computing language. Today it is the predominant language for data science, machine learning, and software development.

A key reason behind Python’s popularity is its flexibility when it comes to adding new features and technologies like magic commands.

So, what exactly is a magic command in Python?

Magic commands are enhancements or shortcuts over the usual Python syntax designed to facilitate routine tasks.

These special commands enable us to easily control the behavior of the IPython system and solve various common problems in standard data analysis, for example, running an external script or calculating the execution time of a piece of code. …


Learn how to download image files using Python modules like request, urllib and wget.

Source: Giphy

Recently, I was working with a remote system and needed to download some images that my code will eventually process.

I could have used curl or wget on my terminal for downloading files. But, I wanted the entire process to be automated for the end-user.

This led me to the question:

In this tutorial, I will cover several modules that can be used for downloading files in Python(specifically images). The modules covered are: requests, wget, and urllib.

Setup

Code used in this tutorial was tested on an Ubuntu system with Python 3.6.9


A quick guide for designing smart, user-friendly Python Dictionaries

Image for post
Image for post
Photo by Aaron Burden on Unsplash

Last week while working on a hobby project, I encountered a very interesting design problem:

Let me explain.

About

Chaitanya Baweja

Machine Learning Engineer | Python | Data Analytics | Economics | Physics

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