Uninstall a Package in Python using PIP

In this short guide, you’ll see how to uninstall a package in Python using PIP. If you’re using Windows, you’ll be able to uninstall a Python package by opening the Windows Command Prompt, and then typing this command: Copy pip uninstall package_name Note: the above method would only work if you already added Python to … Read more

How to Create Pandas DataFrame in Python

In this short guide, you’ll see two different methods to create Pandas DataFrame: Method 1: typing the values in Python to create Pandas DataFrame To create Pandas DataFrame in Python, you can follow this generic template: Copy import pandas as pd data = {‘first_column’: [‘first_value’, ‘second_value’, …],         ‘second_column’: [‘first_value’, ‘second_value’, …], … Read more

How to Export Pandas DataFrame to a CSV File

In order to export Pandas DataFrame to a CSV file in Python: Copy df.to_csv(r”Path to store the exported CSV file\File Name.csv”, index=False) And if you wish to include the index, then simply remove “, index=False” from the code: Copy df.to_csv(r”Path to store the exported CSV file\File Name.csv”) Steps to Export Pandas DataFrame to a CSV … Read more

Delete a File or Folder Using Python

In this short guide, you’ll see how to delete a file or folder using Python. In particular, you’ll see how to: To start, here is the general syntax to delete a file or folder: Delete a file Copy import os os.remove(r”Path where the file is stored\File Name.File type”) Delete an empty folder Copy import os … Read more

Example of Multiple Linear Regression in Python

In this guide, you’ll see how to perform multiple linear regression in Python using both sklearn and statsmodels. The Example In the following example, you’ll see how to perform multiple linear regression for a fictitious economy, where the index_price is the dependent variable, and the 2 independent/input variables are: Please note that you’ll have to … Read more

How to Import an Excel File into Python using Pandas

To import an Excel file into Python using Pandas: Copy import pandas as pd df = pd.read_excel(r”Path where the Excel file is stored\File name.xlsx”) print(df) And if you have a specific Excel sheet that you’d like to import, you may then apply: Copy import pandas as pd df = pd.read_excel(r”Path of Excel file\File name.xlsx”, sheet_name=”your … Read more

Upgrade PIP in Anaconda

In order to upgrade PIP to the latest version, simply run the following command in the Anaconda Prompt: Copy python -m pip install –upgrade pip Steps to Upgrade PIP in Anaconda Step 1: Open the Anaconda Prompt First, open the Anaconda Prompt. You’ll then see a screen with your user name: Copy (base) C:\Users\Ron> Step … Read more

Create a Yes/No Message Box in Python using tkinter

In this short guide, you’ll see how to create a Yes/No message box in Python using tkinter. This includes: The code used to create the Yes/No message box in Python Here is the full code to create the Yes/No message box in Python using tkinter. In the next section, you’ll see an explanation about each … Read more

How to Apply SQL in Python using sqlite3

In this short guide, you’ll see how to apply SQL in Python using sqlite3 by: Steps to Apply SQL in Python using sqlite3 Step 1: Create a database and tables using sqlite3 In this step, you’ll see how to create: Where the ‘items‘ table would contain the following columns and data: item_id item_name 1 Microwave … Read more