How to Remove Duplicates in Pandas DataFrame

To remove duplicates across the entire DataFrame: Copy df.drop_duplicates() To remove duplicates under a single DataFrame column: Copy df.drop_duplicates(subset=[“column_name”]) Steps to Remove Duplicates in Pandas DataFrame Step 1: Gather the data that contains the duplicates Firstly, you’ll need to gather the data that contains the duplicates. Here is an example of data that contains duplicates: … Read more

How to Export Pandas DataFrame to JSON File

The following syntax can be used to export Pandas DataFrame to a JSON file: Copy df.to_json(r’Path to store the exported JSON file\File Name.json’) Next, you’ll see the steps to apply this syntax in practice. Steps to Export Pandas DataFrame to JSON Step 1: Gather the Data Let’s suppose that you have the following data about … Read more

How to Concatenate Lists in Python

You can use the plus operator (‘+’) in order to concatenate lists in Python: Copy concatenated_list = list_1 + list_2 For example, let’s say that you want to concatenate the following two lists: Copy products_1 = [‘computer’, ‘tablet’, ‘printer’, ‘monitor’] products_2 = [‘keyboard’, ‘mouse’, ‘laptop’, ‘scanner’] You can then use the + operator to concatenate … Read more

How to Insert Values into SQL Server Table using Python

In this short guide, you’ll see the complete steps to insert values into SQL Server table using Python. Here are the steps that you may follow. Steps to Insert Values into SQL Server Table using Python Step 1: Install the Pyodbc Package If you haven’t already done so, install the pyodbc package using the command below … Read more

How to add Python to Windows PATH

There are few ways to add Python to Windows PATH. In this short guide, you’ll see two methods to add Python to Windows path: Method 1: Install a Recent Version of Python You can easily add Python to Windows path by downloading a recent version of Python, and then checking the box to Add Python … Read more

Create a Pivot Table in Python using Pandas

In this guide, you’ll see how to create a pivot table in Python using Pandas. More specifically, you’ll observe how to pivot your data across 5 different scenarios. Steps to Create a Pivot Table in Python using Pandas Firstly, you’ll need to capture the data in Python. You can accomplish this task using Pandas DataFrame: … Read more

IF, ELIF and ELSE in Python (with Examples)

Here is a template that you may reference when performing IF, ELIF and ELSE in Python: Copy if condition_1: perform an action if condition_1 is met elif condition_2: perform an action if condition_2 is met else: perform an action if neither condition_1 nor condition_2 is met Next, you’ll see the following 4 examples:  IF and … Read more

How to Schedule Python Script using the Windows Scheduler

In this guide, you’ll see the steps to schedule a Python script using the Windows Scheduler. Here are the steps: Steps to Schedule Python Script using Windows Scheduler Step-1: Prepare the Python Script For example, let’s suppose that the goal is to display ‘Hello World‘ each day at 6am. Here is the Python script to be … Read more

How to Sort Pandas DataFrame (with examples)

You may use df.sort_values in order to sort Pandas DataFrame. In this short guide, you’ll see 4 examples of sorting: To start with a simple example, let’s say that you have the following data about cars: Brand Price Year HH 22000 2015 TT 25000 2013 FF 27000 2018 AA 35000 2018 You can then capture that … Read more

Install Python Package in Anaconda

The following command can be used to install a Python package in Anaconda: Copy pip install package_name Steps to Install a Python Package in Anaconda Step 1: Open the Anaconda Prompt Locate your Anaconda Prompt. For example, if you’re using Windows, you can simply type ‘Anaconda Prompt‘ in the Windows Search Bar (and then click … Read more