Matplotlib Scatter Plot with Distribution Plots (Joint Plot) – Tutorial and Examples

Introduction There are many data visualization libraries in Python, yet Matplotlib is the most popular library out of all of them. Matplotlib’s popularity is due to its reliability and utility – it’s able to create both simple and complex plots with little code. You can also customize the plots in a variety of ways. In this tutorial, we’ll cover how to plot a Joint Plot in Matplotlib which consists of a Scatter Plot and multiple Distribution Plots on the same […]

Read more

Matplotlib Stack Plot – Tutorial and Examples

Introduction There are many data visualization libraries in Python, yet Matplotlib is the most popular library out of all of them. Matplotlib’s popularity is due to its reliability and utility – it’s able to create both simple and complex plots with little code. You can also customize the plots in a variety of ways. In this tutorial, we’ll cover how to plot Stack Plots in Matplotlib. Stack Plots are used to plot linear data, in a vertical order, stacking each […]

Read more

How to Print Colored Text in Python

Introduction It’s typical for CLI apps to return text in the same color of the terminal. There are always cases when we want to highlight output to the user, for example, a warning or error message. In those cases, a dash of color could make a difference. This article shows you how to print colored output in the terminal in Python with and without libraries. ANSI Escape Sequences Your Teletypewriter (TTY), or rather your terminal, is not only capable of […]

Read more

Parse Datetime Strings with parsedatetime in Python

Introduction In this tutorial, we’ll take a look at how to parse Datetime with parsedatetime in Python. To use the parsedatetime package we first need to install it using pip: $ pip install parsedatetime Should pip install parsedatetime fail, the package is also opensource available on Github. Convert String to Python’s Datetime Object with parsedatetime The first, and most common way to use parsedatetime is to parse a string into a datetime object. First, you’ll want to import the parsedatetime […]

Read more

Matplotlib: Draw Vertical Lines on Plot

Introduction Matplotlib is one of the most widely used data visualization libraries in Python. Much of Matplotlib’s popularity comes from its customization options – you can tweak just about any element from its hierarchy of objects. In this tutorial, we’ll take a look at how to draw a vertical line on a Matplotlib plot, that allows us to mark and highlight certain regions of the plot, without zooming or changing the axis range. Creating a Plot Let’s first create a […]

Read more

Validating and Formatting Phone Numbers in Python with phonenumbers

Introduction Validating phone numbers can be a very challenging task. The format of a phone number can vary from one country to another. Heck, it can also vary within the same country! Some countries share the same country code, while some other countries use more than one country code. According to an example from the Google’s libphonenumber GitHub repository, USA, Canada, and Caribbean islands, all share the same country code (+1). On the other hand, it is possible to call […]

Read more

How to Convert DOCX To Html With Python Mammoth

Introduction At some point in your software development path, you’ll have to convert files from one format to another. DOCX (used by Microsoft Word) is a pretty common file format for a lot of people to use. And sometimes, we’d like to convert Word Documents into HTML. This can easily be achieved via the Mammoth package. It’s an easy, efficient, and fast library used to convert DOCX files to HTML. In this article, we’ll learn how to use Mammoth in […]

Read more

Python: How to Print Without Newline or Space

Introduction The print() function in Python appends a newline to the output when displayed on the tty (teletypewriter A.K.A the terminal). When you don’t want your message displayed with newlines or with spaces, how can you change the behavior of print()? This can easily be achieved by altering the default values of the sep and end parameters of the print() function. Printing Without a Newline Until Python version 2.x, print was a reserved keyword that acts as a special statement. […]

Read more

How to Split a List Into Even Chunks in Python

Introduction Splitting strings and lists are common programming activities in Python and other languages. Sometimes we have to split our data in peculiar ways, but more commonly – into even chunks. The language does not have a built-in function to do this and in this tutorial, we’ll take a look at how to split a list into even chunks in Python. For most cases, you can get by using generators: def chunk_using_generators(lst, n): for i in range(0, len(lst), n): yield […]

Read more

How to Sort a Pandas DataFrame by Date

Introduction Pandas is an extremely popular data manipulation and analysis library. It’s the go-to tool for loading in and analyzing datasets for many. Correctly sorting data is a crucial element of many tasks regarding data analysis. In this tutorial, we’ll take a look at how to sort a Pandas DataFrame by date. Let’s start off with making a simple DataFrame with a few dates: import pandas as pd data = {‘Name’:[“John”, “Paul”, “Dhilan”, “Bob”, “Henry”], ‘Date of Birth’: [“01/06/86”, “05/10/77”, […]

Read more
1 3 4 5 6 7 54