How to rename a column by index position in pandas

Follow the steps below to change the names of one or multiple columns by their index number in your Pandas DataFrame. Step # 1: Acquire your DataFrame For this example we will start by importing the pandas library and create a DataFrame with several columns: Note: Make sure to import the pandas library before calling … Read more

How to convert a dictionary with multiple values to pandas DataFrames?

Step 1: Define Python dictionary from lists Here’s the dictionary that we have created: {‘office’: [‘Los Angeles’, ‘New York’, ‘Osaka’, ‘Tokyo’, ‘Buenos Aires’, ‘Bangalore’], ‘interviews’: [104, 148, 166, 213, 149, 187], ‘hired’: [15, 24, 23, 25, 27, 30]} Step 2: Convert multiple values dictionary to DataFrame We can now create a pandas DataFrame from the … Read more

How to multiply pandas Series element wise?

In today’s tutorial we will learn how to calculate the multiplication of multiple pandas series objects as shown below. Data Preparation We will first import pandas and create two series of randomly created numbers: The create two random Series objects, each consisting of 20 elements. Expert Tip: When trying to generate random list, you might … Read more

How to send a video clip message in Teams chat?

Here’s a question from Kitty: I was told by a consultant that he is able to send a simple clip of up to a minute to his colleagues right from the Personal Microsoft Teams Web and Mobile chat. That’s great, but it seems that the IT team has disabled the possibility to record and share … Read more

How to join a path and filename with pathlib?

In this tutorial we will learn how to concatenate a file path and a file name using the pathlib library. Step 1: Import the pathlib library First off, you should make sure to import the Path module which is part of the pathlib package. If you try to use the Path module, before importing it … Read more

How to resize your pandas chart plot figure?

Step 1: Create your pandas DataFrame We’ll import the pandas library and create our DataFrame: Step 2: Plot your Scatter chart We will start by creating a scatter plot our of our DataFrame. Note that we are using the scatter chart for convenience, but you can apply this tutorial to any type of chart such … Read more

How to extract the time only from pandas datetime objects?

Step 1: Create your datetime Series We will start by importing the pandas library into your Python development environment. Next, we will define a simple example DataFrame consisting of sales figures for some random date ranges. Here’s our data: datetime amount 0 2023-06-01 18:30:00-04:00 155 1 2023-06-02 18:30:00-04:00 110 2 2023-06-03 18:30:00-04:00 99 3 2023-06-04 … Read more