How to create a list form a string in Python?

In this short tutorial we will learn how to use the Python string split function to convert single or multiple row strings into list objects which you are able to use for further Data Analysis or automation tasks. Convert string to list of elements in Python Consider the very simple string made of the following … Read more

How to write a Python dictionary into a json file?

In today’s Python automation tutorial we’ll learn how we can quite easily export the contents of a Python dictionary into standalone files that you are able to store for further processing. Specifically we will look into saving dictionaries into json (JavaScript object notation) files which you can store online or on your workstation / server. … Read more

Get time difference in seconds and minutes with Python

In today’s tutorial we will learn how to use how to calculate time differences in Python and Pandas. Find the difference between timestamps in seconds We will start by defining our datetime time stamps. We then define a timedelta. The timedelta is by default expressed in days and hours. Therefore, we then use the total_seconds() … Read more

How to drop the last rows in Pandas DataFrames?

In this tutorial we’ll learn how to remove the one or several last rows of a DataFrame. We’ll be touching on several cases: Getting the last (or last n) rows in a DataFrame. Removing the last (or last n) rows from the DataFrame. Dropping all rows except the first row Drop the last column Example … Read more

How to convert strings to datetime objects in Python?

In today’s quick tutorial we’ll learn how to easily transform string objects to datetime objects. We’ll look into three main topics: Transform a simple string to datetimes. Convert a list of strings to a list of datetime objects Troubleshooting the module not found strptime error Strings to date times in Python 3 The function datetime.datetime … Read more

How to read files into a string in Python 3?

In this short Python tutorial we’ll learn how to load the contents one or multiple files (being both text, csv files) into a string variable object with Python 3. We will cover several scenarios: Load the content of a single text file. Reading multiple text files in a directory. Reading a csv file. Append the … Read more

How to solve the no module named error in Python?

Often times, when developing with Python, we encounter errors related to third party module not found in our development environment. These are generally known as “no module named errors”. In this tutorial we would like to answer several questions related to the topic, so you can easily tackle those issues when trying to import and … Read more