Create Scatter, Line and Bar Charts using Matplotlib

To create scatter plots, line charts, and bar charts using Matplotlib: Scatter plot Copy import matplotlib.pyplot as pltx_axis = [“value_1”, “value_2”, “value_3”, …]y_axis = [“value_1”, “value_2”, “value_3”, …]plt.scatter(x_axis, y_axis)plt.title(“title name”)plt.xlabel(“x_axis name”)plt.ylabel(“y_axis name”)plt.show() Line chart Copy import matplotlib.pyplot as pltx_axis = [“value_1”, “value_2”, “value_3”, …]y_axis = [“value_1”, “value_2”, “value_3”, …]plt.plot(x_axis, y_axis)plt.title(“title name”)plt.xlabel(“x_axis name”)plt.ylabel(“y_axis name”)plt.show() Bar chart … Read more

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