DEV Community

Cover image for 📊 How to Load a Dataset in a Jupyter Notebook Using Pandas
Sana Noor
Sana Noor

Posted on

📊 How to Load a Dataset in a Jupyter Notebook Using Pandas

When you're starting your Machine Learning journey, one of the first things you'll need to learn is how to load your dataset into your Jupyter Notebook.

Let's learn how to do it in the simplest way. 🚀

🐍 Step 1: Import Pandas
import pandas as pd

Here, we're importing the Pandas library and giving it the shorter name pd.

Pandas is a popular Python library used for data analysis and manipulation. It provides useful tools for working with structured data such as CSV files.

📂 Step 2: Load the Dataset
df = pd.read_csv("Dataset.csv")

Let's break this line down:

🔹 pd → The alias we gave to Pandas.

🔹 read_csv() → A Pandas function used to read data from a CSV file.

🔹 "Dataset.csv" → The path or filename of our dataset.

🔹 df → A variable that stores the resulting Pandas DataFrame.

A DataFrame is basically a table of rows and columns that makes it easier to work with our dataset.

You can also load a CSV using a URL:

df = pd.read_csv("https://example.com/dataset.csv")

🔍** Step 3: Take a Quick Look at Your Data**

After loading the dataset, you can check the first few rows:

df.head()

This is a very useful first step because it lets you quickly understand what your dataset looks like.

💡 In short:
import pandas as pd

df = pd.read_csv("Dataset.csv")

df.head()

That's it! 🎉

You've successfully loaded your dataset into a Jupyter Notebook and can now start exploring and preprocessing your data.

I'm also learning these concepts while building my final-year Machine Learning project, so I'll continue sharing what I learn along the way.

If you're also learning Python or Machine Learning, feel free to share your questions in the comments. 👇

See you in the next lesson! 🚀

Python #Pandas #MachineLearning #DataScience #JupyterNotebook #PythonForBeginners #LearningInPublic #100DaysOfCode

Top comments (0)